Python for Data Analysis: Certificate Practice Exam, Exams of Technology

A practice exam for python for data analysis certification. It includes multiple-choice questions covering fundamental python concepts, numpy, and pandas, with detailed explanations for each answer. It is designed to help students and professionals test their knowledge and prepare for certification exams, enhancing their understanding of data analysis techniques using python. The exam covers topics such as data types, operators, list comprehensions, numpy arrays, pandas series and dataframes, and data manipulation techniques. It is a valuable resource for anyone looking to improve their skills in python for data analysis.

Typology: Exams

2025/2026

Available from 12/22/2025

shilpi-jain-1
shilpi-jain-1 🇮🇳

4.2

(5)

29K documents

1 / 100

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Introduction to Python for Data Analysis
Certificate Practice Exam
**Question 1.** Which keyword is used to define a function in Python?
A) func
B) def
C) lambda
D) function
Answer: B
Explanation: The `def` keyword introduces a function definition, followed by the function name
and parameters.
**Question 2.** What will be the output of `type(3.14)`?
A) `<class 'int'>`
B) `<class 'float'>`
C) `<class 'str'>`
D) `<class 'bool'>`
Answer: B
Explanation: `3.14` is a floatingpoint literal, so `type()` returns `<class 'float'>`.
**Question 3.** Which of the following statements correctly casts a string to an integer?
A) `int = "123"`
B) `int("123")`
C) `"123".int()`
D) `cast(int, "123")`
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Python for Data Analysis: Certificate Practice Exam and more Exams Technology in PDF only on Docsity!

Certificate Practice Exam

Question 1. Which keyword is used to define a function in Python? A) func B) def C) lambda D) function Answer: B Explanation: The def keyword introduces a function definition, followed by the function name and parameters. Question 2. What will be the output of type(3.14)? A) <class 'int'> B) <class 'float'> C) <class 'str'> D) <class 'bool'> Answer: B Explanation: 3.14 is a floating‑point literal, so type() returns <class 'float'>. Question 3. Which of the following statements correctly casts a string to an integer? A) int = "123" B) int("123") C) "123".int() D) cast(int, "123")

Certificate Practice Exam

Answer: B Explanation: int("123") converts the numeric string to an integer value 123. Question 4. What is the result of 5 // 2 in Python? A) 2. B) 2 C) 3 D) 2. Answer: B Explanation: The floor division operator // returns the integer quotient, discarding the remainder. Question 5. Which operator tests for equality? A) = B) == C) != D) === Answer: B Explanation: == compares two objects for value equality; = is assignment. Question 6. Given my_list = [1, 2, 3], which method adds an element to the end of the list? A) my_list.add(4)

Certificate Practice Exam

Question 9. Which operation returns the set of elements present in both A and B? A) A | B B) A & B C) A - B D) A ^ B Answer: B Explanation: The & operator computes the intersection of two sets. Question 10. What will be printed by the following code?

x = 10 if x > 5: print("High") elif x > 8: print("Medium") else: print("Low") 

A) High B) Medium C) Low

Certificate Practice Exam

D) Nothing Answer: A Explanation: The first if condition is true, so "High" is printed; subsequent elif is ignored. Question 11. How many times will the loop execute?

count = 0 while count < 3: print(count) count += 1 

A) 2 B) 3 C) 4 D) Infinite Answer: B Explanation: The loop runs while count is 0,1,2 – three iterations. Question 12. Which list comprehension creates a list of squares from 0 to 4? A) [x**2 for x in range(5)] B) [x*2 for x in range(5)]

Certificate Practice Exam

A) np.zeros(3,2) B) np.zeros([3,2]) C) np.zeros((3,2)) D) np.zeros((2,3)) Answer: C Explanation: np.zeros expects a tuple specifying the dimensions. Question 15. What is the dtype of np.array([1, 2, 3.0])? A) int64 B) float64 C) object D) bool Answer: B Explanation: Mixed integer and float literals cause NumPy to upcast to the most general type, which is float64. Question 16. How many dimensions does np.arange(12).reshape(3,4) have? A) 1 B) 2 C) 3 D) 4 Answer: B

Certificate Practice Exam

Explanation: The reshape creates a 2‑D (3×4) array; ndim is 2. Question 17. Which expression extracts the second column from a 2‑D NumPy array A? A) A[:,1] B) A[1,:] C) A[1] D) A[:,2] Answer: A Explanation: : selects all rows; 1 selects column index 1 (the second column). Question 18. What does the following slice return?

arr = np.arange(10) arr[2:8:2] 

A) [2,4,6,8] B) [2,3,4,5,6,7] C) [2,4,6] D) [3,5,7] Answer: C Explanation: Start at index 2, stop before 8, step 2 → elements 2,4,6.

Certificate Practice Exam

C) (5,5)

D) (5,1,1)

Answer: B Explanation: (1,5) can be broadcast to (5,5) and then aligned with (5,1); the singleton dimensions are stretched. Question 22. Which function computes the mean of each column in a 2‑D array M? A) np.mean(M, axis=0) B) np.mean(M, axis=1) C) np.mean(M) D) np.mean(M, axis=2) Answer: A Explanation: axis=0 aggregates along rows, yielding the mean for each column. Question 23. How do you create a Pandas Series from the list [10,20,30] with index labels ['a','b','c']? A) pd.Series([10,20,30], index=['a','b','c']) B) pd.Series([10,20,30], labels=['a','b','c']) C) pd.Series(data=[10,20,30], index=['a','b','c']) D) Both A and C Answer: D Explanation: Both syntaxes are valid; data= is optional.

Certificate Practice Exam

Question 24. Which method reads a CSV file named data.csv while treating the first column as the index? A) pd.read_csv('data.csv', index_col=0) B) pd.read_csv('data.csv', header=0) C) pd.read_excel('data.csv', index_col=0) D) pd.read_csv('data.csv', usecols=0) Answer: A Explanation: index_col=0 tells pandas to use the first column as the row index. Question 25. How can you write a DataFrame df to an Excel file output.xlsx without the index column? A) df.to_excel('output.xlsx', index=False) B) df.to_excel('output.xlsx', header=False) C) df.to_excel('output.xlsx') D) df.save_excel('output.xlsx', index=False) Answer: A Explanation: index=False suppresses writing the DataFrame’s index. Question 26. Which attribute returns the column names of a DataFrame df? A) df.columns B) df.keys() C) df.index D) Both A and B

Certificate Practice Exam

C) Boolean DataFrame of missing entries D) None of the above Answer: A Explanation: isna() creates a boolean mask; sum() aggregates True values (treated as 1) column‑wise. Question 30. Which method replaces missing values in column 'score' with the column’s mean? A) df['score'].fillna(df['score'].mean(), inplace=True) B) df['score'].replace(np.nan, df['score'].mean()) C) df.fillna(df['score'].mean()) D) df['score'].dropna() Answer: A Explanation: fillna replaces NaNs with the supplied value; inplace=True modifies the column directly. Question 31. How can you change the data type of column 'date' to datetime? A) df['date'] = pd.to_datetime(df['date']) B) df['date'].astype('datetime64') C) df.convert_dtype('date', 'datetime') D) Both A and B Answer: D Explanation: Both pd.to_datetime and astype('datetime64[ns]') convert the column.

Certificate Practice Exam

Question 32. Which function removes duplicate rows, keeping the first occurrence? A) df.drop_duplicates(keep='first') B) df.duplicated() C) df.unique() D) df.remove_duplicates() Answer: A Explanation: drop_duplicates removes repeats; keep='first' retains the first row. Question 33. After executing grouped = df.groupby('category'), which method computes the average of each numeric column per category? A) grouped.mean() B) grouped.avg() C) grouped.aggregate('mean') D) Both A and C Answer: D Explanation: Both .mean() and .aggregate('mean') produce the same result. Question 34. Which call creates a pivot table that shows the sum of 'sales' for each 'region' and 'product' combination? A) df.pivot_table(values='sales', index='region', columns='product', aggfunc='sum') B) df.pivot(values='sales', index='region', columns='product') C) df.groupby(['region','product']).sum() D) Both A and C

Certificate Practice Exam

B) ax.set_title('Revenue Over Time') C) plt.title('Revenue Over Time') D) Both B and C Answer: D Explanation: set_title works on a specific Axes; plt.title sets the title of the current Axes. Question 38. Which command displays a histogram of the array data with 20 bins? A) plt.hist(data, bins=20) B) plt.bar(data, bins=20) C) plt.histogram(data, 20) D) plt.plot(data, kind='hist') Answer: A Explanation: plt.hist creates a histogram; bins specifies the number of intervals. Question 39. In Seaborn, which function creates a kernel density estimate plot? A) sns.kdeplot() B) sns.histplot(density=True) C) sns.distplot() D) Both A and C Answer: D Explanation: Both kdeplot and the older distplot (with kde=True) produce KDEs; histplot can also show KDE when kde=True but the direct function is kdeplot.

Certificate Practice Exam

Question 40. Which Seaborn function is best for visualizing pairwise relationships in a dataset df? A) sns.pairplot(df) B) sns.heatmap(df.corr()) C) sns.boxplot(df) D) sns.scatterplot(df) Answer: A Explanation: pairplot creates a matrix of scatter plots (and histograms) for each variable pair. Question 41. What does the following code produce?

sns.boxplot(x='category', y='price', data=df) 

A) A box plot of price for each category B) A scatter plot of price vs category C) A histogram of price D) A bar chart of average price per category Answer: A Explanation: boxplot visualizes distribution (median, quartiles, outliers) of price grouped by category.

Certificate Practice Exam

Answer: A Explanation: cmap specifies the Matplotlib colormap used for the heatmap. Question 45. Which of the following best describes univariate analysis? A) Examining relationships between two variables B) Summarizing a single variable’s distribution C) Clustering observations D) Performing regression Answer: B Explanation: Univariate analysis focuses on one variable at a time, typically using histograms, box plots, etc. Question 46. Which plot is most suitable for detecting outliers in a numeric variable? A) Scatter plot B) Box plot C) Line plot D) Pie chart Answer: B Explanation: Box plots display quartiles and whiskers, making extreme points (outliers) evident. Question 47. Which NumPy function returns the indices of the maximum values along an axis? A) np.argmax() B) np.max()

Certificate Practice Exam

C) np.where() D) np.maxloc() Answer: A Explanation: np.argmax gives the index of the first occurrence of the maximum. Question 48. What will np.arange(0, 1, 0.2) produce? A) [0, 0.2, 0.4, 0.6, 0.8] B) [0, 0.2, 0.4, 0.6, 0.8, 1.0] C) [0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2] D) array([0, 0.2, 0.4, 0.6, 0.8, 1.0]) Answer: A Explanation: np.arange stops before the stop value; with step 0.2 it generates 0 through 0.8. Question 49. Which statement correctly creates a Pandas DataFrame from a dictionary d = {'A':[1,2], 'B':[3,4]}? A) pd.DataFrame(d) B) pd.Series(d) C) pd.DataFrame([d]) D) pd.read_dict(d) Answer: A Explanation: Passing a dict of equal‑length lists to pd.DataFrame creates columns A and B.