- Home
- Subjects
- Data Science
Data Science MCQs · Page 20
1,613 multiple choice questions with answers across 28 topics.
-
A
84, because a cross join returns every possible pairing of the two row sets
Correct answer
-
B
19, because a cross join appends the second table's rows directly onto the first
-
C
12, because only rows of the first table drive the result of the join
-
D
7, because the smaller table determines the number of output rows
-
A
AVG cannot appear in both the select list and the filter of the same query
-
B
The GROUP BY clause must also list AVG(salary) explicitly so the aggregate has a name
-
C
Aggregates are only permitted in the select list and in the ORDER BY clause
-
D
WHERE runs before grouping, so no aggregate exists yet; HAVING must filter instead
Correct answer
-
A
It counts every row, because COUNT ignores the NULL result of the CASE expression
-
B
It counts late rows twice, since the CASE duplicates every row that matches
-
C
It fails, because COUNT cannot accept a CASE expression as its only argument
-
D
It counts only late rows, because the CASE yields NULL for all other statuses
Correct answer
-
A
NULLIF(items, 0), which returns NULL for a zero divisor so the result becomes NULL
Correct answer
-
B
COALESCE(items, 0), which substitutes a zero divisor so that the division stays exact
-
C
NULLIF(items, 0), which replaces NULL divisors with zero and skips those rows
-
D
COALESCE(items, 0), which converts a zero divisor into a NULL before dividing
-
A
It returns the same rows as NOT EXISTS would, since NULLs are ignored by NOT IN
-
B
It raises an error, because NOT IN refuses subqueries that can produce NULL
-
C
It returns only the rows whose key is itself NULL, treating NULL as a match
-
D
It returns no rows at all, because every comparison with NULL yields unknown
Correct answer
-
A
The original column named total, since aliases are never visible to ORDER BY
-
B
A positional reference, because total is parsed as the second select expression
-
C
A re-evaluated expression, since ORDER BY recomputes price times qty again
-
D
The output column alias, which ORDER BY accepts even though WHERE does not
Correct answer
-
A
LIMIT samples rows randomly unless a repeatable seed is supplied with the statement
-
B
Without ORDER BY no row order is guaranteed, so the plan may return any ten rows
Correct answer
-
C
LIMIT is applied before the WHERE clause, so different rows qualify on each run
-
D
The table's primary key is used implicitly, and keys are regenerated on each read
-
A
Only the city column, because DISTINCT applies to the first selected expression only
-
B
Only the country column, since the last expression in the list takes precedence
-
C
Both columns independently, producing the cross product of unique values
-
D
Whole (city, country) pairs, so a city may still appear once per distinct country
Correct answer
-
A
It forms implicit groups from every selected column of the query output
-
B
It filters the single implicit group, returning either one row or no rows at all
Correct answer
-
C
It is a syntax error, because HAVING always requires an explicit GROUP BY clause
-
D
It filters individual rows before aggregation, exactly as a WHERE clause would
-
A
1.0, because balanced weighting only rescales the intercept term of the model
-
B
0.1, because the minority class is down-weighted to match the majority count
-
C
5.0, computed as n_samples divided by the product of classes and positives
Correct answer
-
D
10.0, computed as the ratio of negatives to positives in the training data
-
A
Exactly 95 components, because an integer below 1 is read as a component count
-
B
Components that individually explain at least 95% of the total variance each
-
C
95% of the original columns, chosen by their correlation with the first component
-
D
The smallest number of components whose cumulative explained variance reaches 95%
Correct answer
-
A
Only numeric columns, since passthrough drops anything it cannot encode
-
B
Encoded columns followed by every unlisted column appended unchanged in order
Correct answer
-
C
Only the encoded columns, because remainder='passthrough' keeps no other column at all
-
D
The encoded columns plus a copy of the input frame, so all columns appear twice
-
A
pipeline.set_params(model.C=0.1), using dotted attribute notation for the step
-
B
pipeline.set_params('model__C'=0.1), passing the parameter name as a quoted string
-
C
pipeline.set_params(model__C=0.1), using the step name and a double underscore
Correct answer
-
D
pipeline.set_params(C=0.1), because parameters are flattened onto the pipeline itself
-
A
StratifiedKFold with 5 splits, which preserves each class ratio inside every fold
Correct answer
-
B
KFold with 5 splits and no shuffling, which keeps the original row ordering fully intact
-
C
LeaveOneOut, because grid search always maximises the number of fitted models
-
D
TimeSeriesSplit, because f1 scoring requires chronologically ordered folds here
-
A
The score is compared with the training mean, which recentres the decision boundary
-
B
The sign of the score decides the class, with positive scores mapped to classes_[1] here
Correct answer
-
C
The score is thresholded at 0.5, exactly mirroring a probability cut-off on a calibrated model
-
D
The class with the larger absolute score wins, regardless of the score's overall sign
-
A
It fills the column with zeros, because an undefined mean is replaced by zero
-
B
It raises a ValueError, since no statistic at all can be computed from an empty column
-
C
It keeps the column and fills it with NaN, preserving the missing-value marker
-
D
It drops the column from the transformed output and ignores it during transform
Correct answer
-
A
The number of clusters tested, since n_init is simply an alias for n_clusters in the API
-
B
The number of bootstrap samples used to estimate cluster stability scores
-
C
The number of independent initialisations, with the lowest-inertia run being kept
Correct answer
-
D
The number of iterations allowed inside a single Lloyd run before it stops
-
A
It imposes an arbitrary ordinal order, which the model then treats as numeric distance
Correct answer
-
B
It fails on columns that contain more than two distinct categories at once
-
C
It returns one-hot columns, which cause perfect multicollinearity in the design matrix
-
D
It only works on the target vector, so calling it on a feature column raises an error
-
A
It sets the number of trees to the core count, overriding n_estimators entirely
-
B
It spreads independent fits over all available cores, without changing the results
Correct answer
-
C
It repeats the fit once per available core and averages the resulting forests together
-
D
It disables parallel execution, because -1 means a single worker thread here
-
A
The scaler requires the test set to be a subset of the training rows it was fitted on
-
B
Fitting on the test set leaks its statistics into preprocessing and inflates scores
Correct answer
-
C
transform must be called before fit on the training set to establish the column order
-
D
fit_transform on the test set is slower, yet returns an identical result
-
A
The confusion matrix sum, which grows whenever accuracy is artificially high
-
B
R-squared, which measures how much variance the fraud labels explain overall
-
C
Balanced accuracy, which averages recall across both classes and lands near 0.50
Correct answer
-
D
Precision, which stays high because most of the predicted negatives are truly negative
-
A
The rows are shuffled in place, so the original DataFrame's order is permanently changed
-
B
The same split is produced on repeated runs with the same inputs and library version
Correct answer
-
C
Every run is statistically independent, so no split pattern can ever repeat itself
-
D
The split is stratified automatically, keeping class proportions in both partitions
-
A
The @ prefix escapes the name, allowing identifiers that are not valid Python
-
B
The @ prefix resolves the name in the caller's scope instead of as a column label
Correct answer
-
C
The @ prefix marks the referenced name as a pandas Series, so query can broadcast it
-
D
The @ prefix disables parsing of the expression, passing it to Python's eval directly
-
A
It drops the grouping columns entirely, since apply only ever sees the remaining value columns
-
B
It raises an error, because apply callbacks returning DataFrames are no longer supported
-
C
It duplicates the keys as columns and as index levels, producing redundant result fields
-
D
It prepends the group keys to the result index, so include_groups=False changes the output
Correct answer
-
A
The whole column b is set to 1 for every row, since the mask is ignored here
-
B
Nothing changes in df, because the chained assignment writes to a temporary copy
Correct answer
-
C
Column b is updated for the matching rows, exactly as an equivalent .loc assignment would
-
D
A SettingWithCopyWarning is raised and the assignment is then silently applied