wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Bounty Quiz - Part 2

Total questions: 100

Worksheet time: 1hrs 15mins

Name
Class
Date
1.

What is the output of [1,2,3] + [4,5,6] in Python?

a)

[5, 7, 9]

b)

[1, 2, 3, 4, 5, 6]

c)

Error

d)

[[1,2,3], [4,5,6]]

2.

Given x = [1, 2, 3] and y = x, then y[0] = 10. What is the value of x[0]?

a)

1

b)

10

c)

None

d)

Error

3.

What is the result of 5 // 2 in Python 3?

a)

2.5

b)

2

c)

3

d)

2.0

4.

Given nums = [1, 2, 3, 4, 5], what does nums[-2:] return?

a)

[4, 5]

b)

[2, 3]

c)

[1, 2]

d)

[3, 4]

5.

What sequence does list(range(10, 1, -2)) generate?

a)

[10, 8, 6, 4, 2]

b)

[10, 8, 6, 4, 2, 0]

c)

[1, 3, 5, 7, 9]

d)

[2, 4, 6, 8, 10]

6.

What type of error occurs when executing s = "hello"; s[0] = 'H'?

a)

SyntaxError

b)

TypeError

c)

ValueError

d)

AttributeError

7.

Given a = [1, 2, 3] and b = [1, 2, 3]. Which statement is True?

a)

a == b is False, a is b is True

b)

a == b is True, a is b is True

c)

a == b is True, a is b is False

d)

a == b is False, a is b is False

8.

Given matrix = [[1,2,3], [4,5,6], [7,8,9]], which list comprehension extracts diagonal elements?

a)

[matrix[i][i] for i in range(len(matrix))]

b)

[row[i] for i, row in enumerate(matrix)]

c)

Both A and B

d)

[matrix[i][j] for i in range(3) for j in range(3) if i==j]

9.

What is the key difference between list.sort() and sorted(list)?

a)

sort() returns a new list, sorted() modifies in place

b)

sort() modifies in place and returns None, sorted() returns a new list

c)

Both return a new list

d)

Both modify in place

10.

What happens when you execute d = {'a': 1, 'b': 2}; d['c']?

a)

Returns None

b)

Returns 0

c)

Raises KeyError

d)

Returns empty string

11.

What does lambda x: x**2 if x > 0 else 0 return for input -5?

a)

25

b)

-25

c)

0

d)

Error

12.

Given nums = [1, 2, 3, 4, 5] and result = [x for i, x in enumerate(nums) if i != nums.index(x)], what is result?

a)

[1]

b)

[2, 3, 4, 5]

c)

[1, 2, 3, 4, 5]

d)

[1]

13.

Consider: a = [[1, 2], [3, 4]]; b = a[:]; b[0][0] = 99. What is a[0][0]?

a)

1

b)

99

c)

None

d)

Error

14.

What is the time complexity of x in my_list for a list with n elements?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n2)O(n^2)

15.

Given def func(x, lst=[]): lst.append(x); return lst, what happens when you call func(1) then func(2) separately?

a)

Returns [1] then [2]

b)

Returns [1] then [1, 2]

c)

Returns [2] then [2]

d)

Error

16.

What is the default color space when reading an image using cv2.imread()?

a)

RGB

b)

BGR

c)

Grayscale

d)

HSV

17.

If an image has shape (480, 640, 3), what does the first dimension (480) represent?

a)

Width

b)

Height

c)

Number of channels

d)

Depth

18.

What does cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) do?

a)

Converts BGR to RGB

b)

Converts BGR to grayscale using weighted average

c)

Takes only the first channel

d)

Inverts the image colors

19.

In cv2.GaussianBlur(img, (5,5), 0), why must the kernel size be odd numbers?

a)

For faster computation

b)

To have a center pixel for the kernel

c)

OpenCV requirement only, no mathematical reason

d)

To reduce memory usage

20.

When applying cv2.threshold(gray_img, 127, 255, cv2.THRESH_BINARY), what is a potential problem?

a)

It's too slow

b)

Hard threshold can lose edge information near the threshold value

c)

It only works on color images

d)

Memory overflow

21.

In Canny edge detection, why are two thresholds needed?

a)

One for upper edge, one for lower edge

b)

One for strong edges, one for weak edges that connect to strong edges

c)

One for vertical edges, one for horizontal edges

d)

For redundancy and error checking

22.

If you resize an image from 1000×1000 to 100×100 and then back to 1000×1000, what happens?

a)

You get the exact original image

b)

Image quality is lost due to downsampling

c)

Image becomes sharper

d)

Only color information is lost

23.

In cv2.CascadeClassifier face detection, how does the scaleFactor parameter affect performance?

a)

Larger scaleFactor = faster but may miss faces

b)

Larger scaleFactor = slower but more accurate

c)

It only affects memory usage

d)

It has no effect on detection

24.

In morphological operations, what does Opening (Erosion then Dilation) remove?

a)

Large white regions

b)

Small white noise

c)

Small black holes

d)

Large black regions

25.

When using cv2.warpAffine(), what determines the output image dimensions?

a)

Only the transformation matrix

b)

Only the input image size

c)

The dsize parameter must be specified explicitly

d)

Automatically calculated from matrix

26.

What is the result of np.array([1,2,3]) * 2?

a)

[1, 2, 3, 1, 2, 3]

b)

[2, 4, 6]

c)

6

d)

Error

27.

Given arr = np.array([[1,2,3],[4,5,6]]), what does arr.shape return?

a)

(2, 3)

b)

(3, 2)

c)

6

d)

(6,)

28.

If a = np.array([1,2,3]) and b = np.array([4,5,6]), what is np.dot(a, b)?

a)

[4, 10, 18]

b)

32

c)

[5, 7, 9]

d)

[[4,5,6],[8,10,12],[12,15,18]]

29.

How many elements does np.arange(0, 1, 0.1) create?

a)

9

b)

10

c)

11

d)

100

30.

Given arr = np.array([1,2,3,4,5]), what does arr[arr > 2] return?

a)

[True, True, True, False, False]

b)

[3, 4, 5]

c)

[False, False, True, True, True]

d)

Error

31.

What is the shape of np.array([1,2,3]) + np.array([[1],[2],[3]])?

a)

(3,)

b)

(3, 1)

c)

(3, 3)

d)

Error

32.

You have feature matrix x with shape (1000, 50). To compute mean of each feature, which axis do you use?

a)

axis=0

b)

axis=1

c)

axis=None

d)

No axis needed

33.

Given arr = np.array([[1,2,3],[4,5,6]]), what is the result of np.sum(arr, axis=1)?

a)

[5, 7, 9]

b)

[6, 15]

c)

21

d)

[[1,2,3],[4,5,6]]

34.

What's the difference between np.zeros((3,3)) and np.empty((3,3))?

a)

No difference

b)

zeros() initializes to 0, empty() has arbitrary values

c)

empty() initializes to 0, zeros() has arbitrary values

d)

empty() is always faster

35.

For matrices A (100x50) and B (50x100), which operations are valid?

a)

Only np.dot(A, B)

b)

Only A @ B

c)

Both np.dot(A, B) and A @ B

d)

Neither operation is valid

36.

Why is np.random.seed(42) important in ML experiments?

a)

Makes code run faster

b)

Ensures reproducibility of random operations

c)

Reduces memory usage

d)

Prevents errors

37.

You have data x with shape (10000, 100) and want random batches of size 32. Which approach is most efficient?

a)

Use for loop with random selection

b)

Use np.random.permutation() then slice

c)

Use np.random.choice() for each batch

d)

Manually shuffle each time

38.

For broadcasting, A has shape (5, 3) and b has shape (3,). What is the result shape of A * b?

a)

Error - incompatible shapes

b)

(5, 3)

c)

(5,)

d)

(3,)

39.

Given x with shape (n, d), which formula computes squared Euclidean distance matrix efficiently?

a)

np.sum((X[:, None] - X)**2, axis=2)

b)

np.sum(X**2, axis=1).reshape(-1,1) + np.sum(X**2, axis=1) - 2*np.dot(X, X.T)

c)

Both A and B

d)

Neither is correct

40.

You have weights W (100, 50) and input batch X (32, 100). Which operation is valid?

a)

W @ X

b)

X @ W

c)

Both A and B

d)

Neither A nor B

41.

What's the difference between df['column'] and df[['column']]?

a)

No difference

b)

First returns Series, second returns DataFrame

c)

First returns DataFrame, second returns Series

d)

Both return arrays

42.

What does df.dropna() do?

a)

Removes all data

b)

Removes rows with any missing values

c)

Fills missing values with 0

d)

Removes duplicate rows

43.

If df.shape returns (1000, 5), how many rows and columns are there?

a)

5 rows, 1000 columns

b)

1000 rows, 5 columns

c)

5000 elements total

d)

Cannot determine

44.

What does df.head() return by default?

a)

First row

b)

First 5 rows

c)

First 10 rows

d)

Last 5 rows

45.

Given df['age'] = [25, 30, 35, 40], what does df['age'].mean() return?

a)

30

b)

32.5

c)

35

d)

130

46.

What does df[df['age'] > 30] return?

a)

Boolean array

b)

DataFrame with rows where age > 30

c)

Series of ages > 30

d)

Error

47.

What's the difference between groupby().sum() and groupby().transform('sum')?

a)

No difference

b)

First returns aggregated DataFrame, second returns original shape with aggregated values

c)

First is faster

d)

Second only works with numerical data

48.

In pd.merge(df1, df2, on='id', how='left'), what happens to rows in df1 without matching id in df2?

a)

They are removed

b)

They are kept with NaN for df2 columns

c)

Error is raised

d)

They are duplicated

49.

Why should you use pd.to_datetime() on date strings?

a)

To reduce memory

b)

To enable date-based operations and feature extraction

c)

To sort data

d)

For visualization only

50.

To create time-series sequences of length 10, which Pandas function is most useful?

a)

df.rolling()

b)

df.shift()

c)

df.resample()

d)

df.groupby()

51.

Which operation is generally faster for element-wise operations on DataFrames?

a)

df.apply(lambda x: x**2)

b)

df ** 2

c)

Both are equally fast

d)

Depends on DataFrame size

52.

In pd.get_dummies(df['category'], drop_first=True), why use drop_first=True for linear models?

a)

To save memory

b)

To avoid multicollinearity (dummy variable trap)

c)

To make computation faster

d)

To reduce number of features

53.

When would you use plt.scatter() instead of plt.plot()?

a)

For continuous line plots

b)

For showing individual data points without connections

c)

For bar charts

d)

They are interchangeable

54.

What happens if you create multiple plots without plt.figure() or plt.show()?

a)

Error occurs

b)

Plots overlay on same figure

c)

Each plot creates new window

d)

Nothing happens

55.

What is the purpose of plt.xlabel() and plt.ylabel()?

a)

To title the plot

b)

To label the axes

c)

To add legend

d)

To resize the plot

56.

When plotting training and validation loss, why use plt.legend()?

a)

To make plot colorful

b)

To identify which line represents which metric

c)

To add title

d)

To save the plot

57.

What advantage does sns.heatmap(df.corr(), annot=True) provide?

a)

Faster computation

b)

Visual representation of correlations with values displayed

c)

Uses less memory

d)

Automatically selects important features

58.

Which plot best shows the distribution shape of a continuous variable?

a)

sns.barplot()

b)

sns.scatterplot()

c)

sns.histplot() OR sns.kdeplot()

d)

sns.lineplot()

59.

With fig, axes = plt.subplots(2, 3) creating 6 subplots, how do you access the subplot in 2nd row, 1st column?

a)

axes[0, 1]

b)

axes[1, 0]

c)

axes[1, 1]

d)

axes[2, 1]

60.

When plotting a confusion matrix for imbalanced classes, why normalize by row?

a)

To make values sum to 1

b)

To show percentages per true class, avoiding misleading conclusions

c)

To make the heatmap prettier

d)

To reduce computation time

61.

If input shape is (1, 784) and weight matrix is (784, 128), what is the output shape?

a)

(1, 784)

b)

(1, 128)

c)

(784, 128)

d)

(128, 1)

62.

What does it mean when two vectors are orthogonal?

a)

They are parallel

b)

Their dot product is zero

c)

They have the same magnitude

d)

They point in opposite directions

63.

Given vectors a = [1, 0] and b = [0, 1], what is their dot product?

a)

0

b)

1

c)

[1, 1]

d)

[0, 0]

64.

What happens when you multiply any matrix by the identity matrix?

a)

Matrix becomes zero

b)

Matrix becomes transposed

c)

Matrix remains unchanged

d)

Matrix becomes inverted

65.

What is the dimension of the transpose of a 3x4 matrix?

a)

3x4

b)

4x3

c)

1x21

d)

1x12

66.

In neural networks, what happens if you multiply matrices in wrong order?

a)

Result is transposed

b)

Dimension mismatch error

c)

Same result

d)

Zero matrix

67.

In linear regression solution (XTX)1XTy(X^T X)^{-1} X^T y , what is XTXX^T X ?

a)

Covariance matrix

b)

Square matrix of size (features × features)

c)

Identity matrix

d)

Diagonal matrix

68.

When is a matrix non-invertible?

a)

When it's square

b)

When it's rectangular

c)

When its determinant is zero

d)

When it's symmetric

69.

You have 1000 samples with 10 features. What is the maximum rank of your data matrix?

a)

1000

b)

10

c)

10000

d)

999

70.

In PCA, eigenvectors of the covariance matrix represent:

a)

Original features

b)

Directions of maximum variance

c)

Data points

d)

Error terms

71.

What does L2 regularization term λW2\lambda||W||^2 prevent?

a)

Underfitting

b)

Weight values from becoming too large

c)

Bias in predictions

d)

Data leakage

72.

If a neural network layer maps R^n → R^m, what is the shape of its Jacobian matrix?

a)

(n, n)

b)

(m, n)

c)

(n, m)

d)

(m, m)

73.

Why can we compute softmax(x - max(x)) instead of softmax(x) for numerical stability?

a)

It's faster

b)

Subtracting a constant doesn't change softmax output but prevents overflow

c)

It gives different results

d)

It reduces memory usage

74.

In SVD a = UΣVT, what does Σ represent?

a)

Rotation matrix

b)

Diagonal matrix of singular values

c)

Eigenvectors

d)

Covariance matrix

75.

What is the "curse of dimensionality" effect on KNN?

a)

KNN becomes faster

b)

All points become approximately equidistant, reducing discrimination

c)

Memory usage decreases

d)

Accuracy always improves

76.

What is the goal of Linear Regression?

a)

To classify data into categories

b)

To find the best-fit line that minimizes prediction error

c)

To cluster similar data points

d)

To reduce dimensionality

77.

In the linear regression equation y = mx + b, what does 'm' represent?

a)

Y-intercept

b)

Slope/coefficient

c)

Error term

d)

Learning rate

78.

What loss function does Linear Regression typically minimize?

a)

Cross-entropy loss

b)

Hinge loss

c)

Mean Squared Error (MSE)

d)

Absolute error

79.

If learning rate is too large in gradient descent, what happens?

a)

Convergence is slow

b)

Loss may oscillate or diverge

c)

Training is faster and stable

d)

No effect

80.

What does the gradient in gradient descent represent?

a)

The learning rate

b)

The direction and magnitude of steepest ascent

c)

The final weights

d)

The number of iterations

81.

In gradient descent, we update weights by moving in which direction?

a)

Direction of the gradient

b)

Opposite direction of the gradient

c)

Random direction

d)

Direction of maximum loss

82.

What is the main difference between Ridge and Lasso regression?

a)

Ridge uses L1 penalty, Lasso uses L2 penalty

b)

Ridge uses L2 penalty, Lasso uses L1 penalty

c)

Ridge is for classification, Lasso is for regression

d)

No difference

83.

Why do we need a separate test set in regression?

a)

To train faster

b)

To evaluate generalization to unseen data

c)

To save memory

d)

To reduce computation

84.

What problem does Ridge regression solve that ordinary linear regression doesn't?

a)

Non-linear relationships

b)

Multicollinearity and overfitting by penalizing large coefficients

c)

Missing data

d)

Imbalanced classes

85.

In the Ridge regression cost function: MSE + λ∑(wi²), what happens when λ = 0?

a)

All coefficients become zero

b)

It becomes standard linear regression

c)

Model cannot train

d)

Overfitting is maximized

86.

What is a key property of Lasso regression (L1 regularization)?

a)

It can shrink some coefficients exactly to zero (feature selection)

b)

It always increases all coefficients

c)

It only works with categorical data

d)

It requires no hyperparameter tuning

87.

In batch gradient descent, when do we update the weights?

a)

After each sample

b)

After processing all training samples in an epoch

c)

Randomly during training

d)

Only at the end of training

88.

Why is mini-batch gradient descent often preferred over batch gradient descent?

a)

Always more accurate

b)

Balances computation efficiency and gradient estimation quality

c)

Uses less memory than stochastic

d)

Guaranteed to find global minimum

89.

A linear regression model fits training data perfectly but fails on test data. This indicates:

a)

High bias (underfitting)

b)

High variance (overfitting)

c)

Optimal fit

d)

Data is corrupted

90.

In gradient descent, the update rule is: w = w - α × ∂L/∂w. What does α represent and how does it affect convergence?

a)

Momentum; speeds up training

b)

Learning rate; too small = slow, too large = divergence

c)

Regularization parameter; controls overfitting

d)

Batch size; determines update frequency

91.

For Ridge regression with cost function: (1/n)Σ(yi - ŷi)² + λΣwi², what is the effect of increasing λ?

a)

Coefficients get larger, model complexity increases

b)

Coefficients shrink toward zero, model becomes simpler

c)

No effect on coefficients

d)

Training becomes faster

92.

Why is the linear regression cost function (MSE) convex?

a)

It has multiple local minima

b)

It has a single global minimum, guaranteeing gradient descent convergence

c)

It's non-differentiable

d)

It's always zero

93.

In stochastic gradient descent (SGD), weights are updated:

a)

After seeing all samples

b)

After each individual sample

c)

Only once at the end

d)

Never updated

94.

Given features with very different scales (e.g., age: 0-100, income: 0-1000000), why is feature scaling important for gradient descent?

a)

Makes training faster only

b)

Prevents features with larger scales from dominating gradient updates, ensures balanced convergence

c)

Reduces memory usage

d)

Improves visualization

95.

In the normal equation solution: w=(XTX)1XTyw = (X^T X)^{-1} X^T y , when would this approach fail or be inefficient compared to gradient descent?

a)

When n (samples) is large and d (features) is small

b)

When XTXX^T X is singular (non-invertible) or d is very large (computationally expensive)

c)

When data is normalized

d)

When using regularization

96.

Given predictions [0.1, 0.4, 0.7, 0.9] and true labels [0, 0, 1, 1] with threshold 0.5, what is the accuracy?

a)

50%

b)

75%

c)

100%

d)

25%

97.

For K-fold cross-validation, if you have 100 samples and K=5, how many samples in each fold?

a)

5

b)

10

c)

20

d)

25

98.

In a binary confusion matrix, a False Positive means:

a)

Predicted positive, actually positive

b)

Predicted positive, actually negative

c)

Predicted negative, actually positive

d)

Predicted negative, actually negative

99.

Why is initializing all neural network weights to zero problematic?

a)

Causes overflow

b)

All neurons learn the same features (symmetry problem)

c)

Training is too slow

d)

Prevents backpropagation

100.

You train for 1000 epochs at 5 seconds/epoch with early stopping after 50 epochs of no improvement. If best loss occurs at epoch 100, when does training stop?

a)

Epoch 100

b)

Epoch 150

c)

Epoch 1000

d)

Epoch 50