PrepIQ Data Science with Python Ultimate Exam, Exams of Technology

This practice exam assesses proficiency in Python-based data science, covering data analysis, preprocessing, visualization, statistical modeling, machine learning algorithms, feature engineering, and model evaluation. It includes hands-on coding scenarios requiring candidates to manipulate datasets, build analytical models, interpret results, and deploy solutions. The exam prepares learners to apply Python skills to real-world data challenges across industries.

Typology: Exams

2025/2026

Available from 05/01/2026

shilpi-jain-3
shilpi-jain-3 🇮🇳

2.5

(11)

80K documents

1 / 60

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
PrepIQ Data Science with Python Ultimate Exam
**Question 1.** Which of the following Python data types is immutable?
A) list B) dict C) tuple D) set
**Answer:** C
**Explanation:** Tuples cannot be modified after creation, whereas lists, dicts, and
sets are mutable.
**Question 2.** What is the result of `3 ** 2 // 4`?
A) 2 B) 1 C) 0 D) 3
**Answer:** B
**Explanation:** `3 ** 2` is 9; integer floor division `9 // 4` yields 2, but operator
precedence evaluates exponentiation before floor division, giving 9 // 4 = 2.
**Question 3.** In Python, which keyword is used to create an anonymous function?
A) lambda B) def C) func D) anonymous
**Answer:** A
**Explanation:** The `lambda` keyword defines a small, unnamed function.
**Question 4.** Which of the following statements correctly creates a generator
expression that yields squares of numbers 0-4?
A) `[x**2 for x in range(5)]` B) `{x**2 for x in range(5)}` C) `(x**2 for x in
range(5))` D) `gen = x**2 for x in range(5)`
**Answer:** C
**Explanation:** Parentheses create a generator expression; brackets create a list,
braces a set.
**Question 5.** What does the `LEGB` rule describe in Python?
A) Order of evaluation for arithmetic operators
B) Scope resolution order: Local, Enclosing, Global, Built-in
C) Priority of logical operators
D) Sequence of module import paths
**Answer:** B
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

Partial preview of the text

Download PrepIQ Data Science with Python Ultimate Exam and more Exams Technology in PDF only on Docsity!

Question 1. Which of the following Python data types is immutable? A) list B) dict C) tuple D) set Answer: C Explanation: Tuples cannot be modified after creation, whereas lists, dicts, and sets are mutable. Question 2. What is the result of 3 ** 2 // 4? A) 2 B) 1 C) 0 D) 3 Answer: B Explanation: 3 ** 2 is 9; integer floor division 9 // 4 yields 2, but operator precedence evaluates exponentiation before floor division, giving 9 // 4 = 2. Question 3. In Python, which keyword is used to create an anonymous function? A) lambda B) def C) func D) anonymous Answer: A Explanation: The lambda keyword defines a small, unnamed function. Question 4. Which of the following statements correctly creates a generator expression that yields squares of numbers 0-4? A) [x**2 for x in range(5)] B) {x**2 for x in range(5)} C) (x**2 for x in range(5)) D) gen = x**2 for x in range(5) Answer: C Explanation: Parentheses create a generator expression; brackets create a list, braces a set. Question 5. What does the LEGB rule describe in Python? A) Order of evaluation for arithmetic operators B) Scope resolution order: Local, Enclosing, Global, Built-in C) Priority of logical operators D) Sequence of module import paths Answer: B

Explanation: LEGB defines how Python resolves variable names. Question 6. Which method removes a key-value pair from a dictionary without raising an error if the key is missing? A) pop() B) remove() C) del D) popitem() Answer: A Explanation: dict.pop(key, default) returns a default value instead of raising KeyError. Question 7. What is the output of set([1,2,2,3]) & set([2,3,4])? A) {1, 2, 3, 4} B) {2, 3} C) {1, 2} D) {4} Answer: B Explanation: The & operator returns the intersection of two sets. Question 8. Which of the following statements about list append and extend is true? A) Both add a single element. B) append adds an iterable as one element; extend adds each element individually. C) extend adds a single element; append adds each element individually. D) Both concatenate two lists and return a new list. Answer: B Explanation: append inserts the whole object; extend iterates over the argument. Question 9. Which built-in function converts a string '123' to an integer? A) float('123') B) int('123') C) str('123') D) bool('123') Answer: B Explanation: int() parses a numeric string into an integer. Question 10. What will be printed by the following code?

Question 14. In NumPy, what is the shape of np.zeros((3,4,5))? A) (3, 4, 5) B) (5, 4, 3) C) (12, 5) D) (3, 4) Answer: A Explanation: The shape attribute reflects the dimensions specified. Question 15. Which broadcasting rule allows adding a (3,1) array to a (3,4) array? A) No broadcasting is possible. B) The trailing dimensions must match or be 1. C) Only the first dimension may differ. D) All dimensions must be equal. Answer: B Explanation: NumPy aligns dimensions from the right; a size-1 dimension can be broadcast. Question 16. What does np.mean(arr, axis=0) compute? A) Mean of the entire array B) Mean across rows (column-wise) C) Mean across columns (row-wise) D) Standard deviation across columns Answer: B Explanation: axis=0 collapses the first dimension, giving column-wise means. Question 17. Which NumPy function computes the dot product of two 1-D arrays? A) np.multiply B) np.dot C) np.cross D) np.inner Answer: B Explanation: np.dot returns the scalar dot product for 1-D inputs.

Question 18. Given a = np.array([[1,2],[3,4]]), what is a.T? A) [[1,3],[2,4]] B) [[1,2],[3,4]] C) [[4,3],[2,1]] D) [[2,1],[4,3]] Answer: A Explanation: .T transposes rows and columns. Question 19. Which Pandas object is best suited for representing a single column with an explicit index? A) DataFrame B) Series C) Panel D) Index Answer: B Explanation: A Series is a one-dimensional labeled array. Question 20. How would you select rows 10 through 20 (inclusive) from a DataFrame df using integer-based indexing? A) df.loc[10:20] B) df.iloc[10:21] C) df[10:21] D) df.select(10,20) Answer: B Explanation: iloc uses zero-based slicing where the stop index is exclusive. Question 21. Which method writes a DataFrame to a CSV file without the index column? A) df.to_csv('file.csv', index=False) B) df.save('file.csv') C) df.export('file.csv') D) df.write_csv('file.csv') Answer: A Explanation: to_csv has an index parameter; setting it to False omits the index. Question 22. In Pandas, what does df.isnull().sum() return? A) Total number of rows containing nulls B) Boolean DataFrame indicating nulls C) Count of null values per column D) List of column names with nulls Answer: C

Question 27. Which of the following is NOT a valid Matplotlib backend? A) TkAgg B) Qt5Agg C) SVG D) MacOSX Answer: C Explanation: SVG is a format, not a backend; backends are GUI toolkits. Question 28. In Matplotlib, which function adds a legend to the current axes? A) plt.legend() B) plt.title() C) plt.show() D) plt.xlabel() Answer: A Explanation: legend() creates a legend based on labeled plot elements. Question 29. Which Seaborn function creates a heatmap from a correlation matrix? A) sns.boxplot() B) sns.heatmap() C) sns.distplot() D) sns.pairplot() Answer: B Explanation: heatmap visualizes a 2-D dataset as colored cells. Question 30. What does the regplot function in Seaborn automatically add to a scatter plot? A) Kernel density estimate B) Linear regression line with confidence interval C) Violin plot overlay D) Histogram of residuals Answer: B Explanation: regplot fits and draws a regression line with a shaded CI. Question 31. Which statistical measure quantifies the linear relationship between two variables? A) Covariance B) Correlation coefficient C) Variance D) Median absolute deviation Answer: B Explanation: Correlation standardizes covariance to a range of –1 to 1.

Question 32. In hypothesis testing, a p-value smaller than the significance level (α) leads to which decision? A) Fail to reject the null hypothesis B) Accept the alternative hypothesis without error C) Reject the null hypothesis D) Increase the sample size automatically Answer: C Explanation: A small p-value indicates evidence against the null hypothesis. Question 33. Which SciPy function performs a two-sample independent t-test? A) stats.ttest_ind() B) stats.ttest_rel() C) stats.f_oneway() D) stats.chi2_contingency() Answer: A Explanation: ttest_ind tests means of two independent samples. Question 34. Which distribution models the number of successes in a fixed number of Bernoulli trials? A) Normal B) Poisson C) Binomial D) Exponential Answer: C Explanation: The binomial distribution counts successes over fixed trials. Question 35. What is the purpose of StandardScaler in scikit-learn? A) Scale features to [0,1] range B) Center to mean 0 and unit variance C) Perform PCA automatically D) Encode categorical variables Answer: B Explanation: StandardScaler subtracts the mean and divides by the standard deviation.

C) No change in bias-variance trade-off D) Overfitting regardless of data size Answer: B Explanation: Larger k smooths decision boundaries, reducing variance but increasing bias. Question 41. Which impurity measure is based on the probability of misclassifying a randomly chosen element? A) Gini impurity B) Entropy C) Information gain D) Chi-square Answer: A Explanation: Gini impurity = 1 – Σ p_i², reflecting misclassification probability. Question 42. In a confusion matrix, which cell corresponds to false negatives? A) Top-left B) Top-right C) Bottom-left D) Bottom-right Answer: C Explanation: Rows represent actual class, columns predicted; bottom-left is actual 1 predicted 0. Question 43. The ROC curve plots: A) Precision vs. Recall B) True Positive Rate vs. False Positive Rate C) Accuracy vs. Threshold D) F1 Score vs. Threshold Answer: B Explanation: ROC visualizes the trade-off between sensitivity and 1-specificity. Question 44. Which scikit-learn class implements Principal Component Analysis? A) PCA B) LinearDiscriminantAnalysis C) FactorAnalysis D) TruncatedSVD Answer: A

Explanation: sklearn.decomposition.PCA performs orthogonal dimensionality reduction. Question 45. What does the random_state parameter control in train_test_split? A) Proportion of test data B) Shuffle randomness for reproducibility C) Number of features to select D) Learning rate of downstream model Answer: B Explanation: Setting random_state fixes the pseudo-random seed. Question 46. Which of the following is a valid way to raise a custom exception named MyError? A) raise MyError('msg') B) throw MyError('msg') C) exception MyError('msg') D) error MyError('msg') Answer: A Explanation: raise is the Python keyword for raising exceptions. Question 47. Which NumPy function returns the indices of the maximum values along an axis? A) np.argmax() B) np.max() C) np.where() D) np.argmin() Answer: A Explanation: argmax provides index positions of maxima. Question 48. In Pandas, what does df['col'].astype('category') accomplish? A) Converts the column to numeric type B) Converts the column to a categorical dtype, reducing memory C) Removes duplicate values D) Sorts the column alphabetically Answer: B

Question 53. Which of the following statements about Python’s set type is FALSE? A) Sets are unordered. B) Sets can contain duplicate elements. C) Sets are mutable. D) Sets support mathematical operations like union. Answer: B Explanation: Sets automatically discard duplicate elements. Question 54. What does the pass statement do inside a loop or function? A) Terminates execution of the loop B) Skips to the next iteration C) Does nothing; acts as a placeholder D) Raises a NotImplementedError automatically Answer: C Explanation: pass is a null operation used where syntactic code is required. Question 55. Which of the following correctly imports the sqrt function from the math module with an alias? A) import math as sqrt B) from math import sqrt as sq C) import sqrt from math D) from math sqrt Answer: B Explanation: from math import sqrt as sq imports and renames the function. Question 56. If a = [1,2,3] and b = a, what is the result of b.append(4)? A) a remains [1,2,3] B) b becomes [1,2,3,4] and a unchanged C) Both a and b become [1,2,3,4] D) Raises a ReferenceError Answer: C Explanation: b references the same list object as a; mutation affects both.

Question 57. Which of the following is the correct way to catch multiple specific exceptions in a single except clause? A) except (ValueError, TypeError): B) except ValueError or TypeError: C) except ValueError, TypeError: D) except [ValueError, TypeError]: Answer: A Explanation: Parentheses group exception types for a combined handler. Question 58. In NumPy, what does the np.newaxis object do when used in slicing? A) Adds a new axis of size 1, increasing dimensionality B) Removes an existing axis C) Flattens the array D) Replaces the sliced portion with zeros Answer: A Explanation: np.newaxis expands the shape, useful for broadcasting. Question 59. Which Pandas method returns a DataFrame with duplicate rows removed, keeping the first occurrence? A) drop_duplicates(keep='first') B) unique() C) remove_duplicates() D) filter_duplicates() Answer: A Explanation: drop_duplicates removes repeated rows; default keep='first'. Question 60. In Matplotlib, which command must be called to display the figure in a script? A) plt.show() B) plt.display() C) plt.render() D) plt.plot() Answer: A Explanation: show() renders the figure window. Question 61. Which Seaborn function creates a pairwise scatter plot matrix for a DataFrame?

A) stats.norm.cdf() B) stats.norm.pdf() C) stats.norm.sf() D) stats.norm.ppf() Answer: A Explanation: cdf returns the probability that a normal variable ≤ x. Question 66. In a box plot, what does the line inside the box represent? A) Mean B) Median C) Minimum D) Maximum Answer: B Explanation: The central line marks the median of the distribution. Question 67. Which of the following is true about the train_test_split function’s shuffle parameter? A) When False, data is split sequentially without shuffling. B) When True, it sorts the data before splitting. C) It determines the size of the test set. D) It only works for classification problems. Answer: A Explanation: shuffle=False preserves original order; default is True. Question 68. What does the fit_transform method do in scikit-learn’s preprocessing classes? A) Fits the model on training data and returns transformed training data B) Only fits the model without transformation C) Only transforms data using pre-fitted parameters D) Saves the model to disk Answer: A Explanation: fit_transform combines fit and transform. Question 69. Which algorithm can be used for both classification and regression tasks?

A) K-Nearest Neighbors B) Logistic Regression C) Naïve Bayes D) Linear Discriminant Analysis Answer: A Explanation: K-NN predicts class labels or numeric values based on neighbors. Question 70. In a decision tree, what does a leaf node represent? A) A split based on a feature B) A final prediction (class or value) C) The root of the tree D) The pruning threshold Answer: B Explanation: Leaves contain the output for the region of feature space. Question 71. Which metric is most appropriate for evaluating an imbalanced binary classification where false negatives are costly? A) Accuracy B) Precision C) Recall D) F1-score Answer: C Explanation: Recall (sensitivity) emphasizes detecting positives, reducing false negatives. Question 72. What does the roc_auc_score function compute? A) Area under the ROC curve B) Area under the Precision-Recall curve C) Average precision D) Mean squared error of the ROC points Answer: A Explanation: It returns the scalar AUC value. Question 73. Which of the following is a valid way to create a NumPy array of shape (2,3) filled with the value 7?

Question 78. Which of the following statements about NumPy’s where function is correct? A) It returns indices where a condition is true. B) It only works with 1-D arrays. C) It performs element-wise multiplication. D) It replaces NaN values with zeros. Answer: A Explanation: np.where(condition) yields tuple of index arrays. Question 79. If df['date'] = pd.to_datetime(df['date']), what is the primary benefit? A) Converts strings to Python datetime objects for time-series operations B) Changes column type to categorical C) Removes duplicate dates automatically D) Sorts the DataFrame by date Answer: A Explanation: to_datetime parses strings into datetime64 dtype. Question 80. In Matplotlib, which function creates a subplot grid of 2 rows and 3 columns and returns the Axes array? A) plt.subplot(2,3) B) plt.subplots(2,3) C) plt.figure(2,3) D) plt.grid(2,3) Answer: B Explanation: subplots returns a Figure and an array of Axes. Question 81. Which of the following is NOT a valid Pandas index type? A) RangeIndex B) Int64Index C) FloatIndex D) DatetimeIndex Answer: C Explanation: Pandas does not have a dedicated FloatIndex. Question 82. What does the fillna(method='ffill') method do?

A) Replaces NaN with the column mean B) Replaces NaN with the previous valid observation (forward fill) C) Drops all rows containing NaN D) Replaces NaN with zeros Answer: B Explanation: ffill propagates last valid value forward. Question 83. Which of the following statements about Python’s enumerate function is true? A) Returns a list of tuples (index, element) B) Returns an iterator that yields pairs (index, element) C) Requires a dictionary as input D) Cannot be used in a for loop Answer: B Explanation: enumerate yields (index, item) tuples lazily. Question 84. In NumPy, what is the result of np.array([1,2,3]) @ np.array([4,5,6])? A) Element-wise multiplication array B) Dot product scalar 32 C) Matrix multiplication error D) Array [[4,10,18]] Answer: B Explanation: The @ operator performs dot product for 1-D arrays. Question 85. Which Pandas method combines multiple DataFrames vertically, aligning columns by name? A) pd.concat([df1, df2], axis=0) B) pd.merge(df1, df2, how='outer') C) df1.append(df2) D) Both A and C Answer: D Explanation: Both concat with axis=0 and append stack rows.