MCQ Exercises
Numpy
Q1. Which of the following correctly creates a 2×3 NumPy array?
Q2. What does
Q3. If
Q4. Given
Q5. Which NumPy function computes the square root of every element in an array?
Q6. What does
Q7. Which statement about
Q8. Given
np.linspace(0, 10, 5) produce?
x = np.array([[1,2,3],[4,5,6]]), what is x.shape?
a = np.array([1,2,3,4]), what does a.mean() return?
x.reshape(6,) do to a 2×3 array?
flatten() and ravel() is correct?
x = np.array([[10,20,30],[40,50,60]]), what does x[:,1] return?
Pandas
Q1. Which statement correctly describes a Pandas Series?
Q2. Which command displays the last 5 rows of a DataFrame
Q3. Which function removes all rows containing at least one NA value?
Q4. Which command correctly extracts the columns ‘Age’ and ‘Gender’ as a DataFrame?
Q5. Which command correctly filters rows where age is over 40 and has not experienced heart attack?
Q6. Which command correctly creates a new column storing age 5 years later?
Q7. Which command correctly assigns ‘Male’ when Gender==1 and ‘Female’ otherwise?
Q8. Which command computes mean BMI grouped by Heart_attack status?
df?
Scikitlearn
Q1. From which module do you import
Q2. Which statement about preparing the outcome for logistic regression is correct?
Q3. What is the purpose of
Q4. Which statement correctly compares LASSO and Ridge regression?
Q5. Which statement correctly describes how KNN makes predictions?
LinearRegression?
train_test_split()?
Matplotlib
Q1. Which statement correctly describes the relationship between a Figure and an Axes in Matplotlib?
Q2. Which command correctly creates a 2×2 grid of subplots?
Q3. Which command correctly creates a scatterplot on an Axes object?
Q4. Which command correctly creates a histogram of Age with 10 bins and visible bin edges?
Q5. Which statement correctly describes the components of a Matplotlib boxplot?