- Home
- MCQs by exam
- Interviews
- Data Science
Interviews MCQs – Data Science · Page 2
231 multiple choice questions typical of the Interviews exam, with answers and explanations. Switch on practice mode to test yourself first.
-
A
It applies weak regularisation, allowing the coefficients to grow freely
-
B
It disables regularisation entirely, matching unpenalised maximum likelihood
-
C
It caps the number of solver iterations, so the fit stops early in training
-
D
It applies strong regularisation, shrinking the coefficients toward zero
Correct answer
-
A
Columns prefixed with x_ and y_, aligned on the shared index labels
-
B
A dictionary of the two frames keyed by x and y instead of a frame
-
C
A MultiIndex whose outer level records which frame each row came from
Correct answer
-
D
A new column named keys holding x or y for each contributing row of both
-
A
Both must share a MultiIndex, since asof merges only on index keys
-
B
Both must contain no duplicate keys, because asof performs an inner join
-
C
Both must be sorted by the key column, which has to hold ordered data
Correct answer
-
D
Both must have identical dtypes for every shared column in the frames
-
A
It shifts the values one row down and leaves the index labels untouched
-
B
It resamples the series to daily frequency before shifting the values
-
C
It fills the vacated rows with the previous value instead of with NaN
-
D
It shifts the index labels by a day, keeping values with their labels
Correct answer
-
A
A running count within its own group, starting again at zero per group
Correct answer
-
B
A running count across the whole frame, ignoring the group boundaries
-
C
The total number of rows in its group, broadcast back to every member
-
D
A cumulative sum of those counts, so the last row holds the group size
-
A
NaN entries are replaced by whatever the function happens to return for a NaN
-
B
NaN entries pass through untouched instead of being sent to the function
Correct answer
-
C
NaN entries raise an error rather than being silently forwarded to func
-
D
The mapping dictionary's NaN key is used, overriding any default value
-
A
The interval from 0 up to 10, because right=False moves the closed edge
-
B
The interval from 10 up to 20, because right=False makes bins left-closed
Correct answer
-
C
The interval from 0 up to 10, since the default includes the right edge
-
D
A missing category, because the value 10 sits exactly on a bin boundary point
-
A
All three 9 values, because ties are always retained by nlargest
-
B
Two 9 values, chosen by their index labels rather than by position
-
C
Three rows followed by a truncation warning from pandas about ties
-
D
Two of the tied 9 values, ordered by their position in the Series
Correct answer
-
A
where keeps values where the condition holds; mask replaces them there
Correct answer
-
B
where replaces values where the condition holds; mask keeps them
-
C
where drops the rows failing the condition; mask keeps them and fills in
-
D
The two are aliases, and only their argument order differs from each other
-
A
The original shape, with the missing values dropped by the round trip
-
B
A transposed frame, because unstack reverses the axes rather than stack
-
C
A frame with one extra level, since stack keeps every level intact
-
D
The original shape, with the same missing values still in place there
Correct answer
-
A
The frame sorted by the year level, keeping only the first matching rows
-
B
The year level reset into an ordinary column of the same DataFrame
-
C
A grouped object that aggregates the values for 2021 by the other index level
-
D
A cross-section at one index level, with that level dropped from the result
Correct answer
-
A
NaN in the extracted column, because a non-match yields a missing value
Correct answer
-
B
An empty string, because extract returns the unmatched part of the input
-
C
The original value unchanged, since extract only rewrites matching rows
-
D
An error, because extract requires every value to match the pattern
-
A
It splits each string on commas into separate columns, one per element
-
B
It flattens the whole column into a single Series of concatenated list values
-
C
It expands the lists into new columns named tags_0, tags_1 and so on
-
D
It gives each list element its own row, repeating the other column values
Correct answer
-
A
tz_convert on the index, because it attaches a zone to a naive index
-
B
astype to a datetime64 value with the UTC unit, which attaches the zone
-
C
tz_localize(None), which labels the index as UTC without adding a zone
-
D
tz_localize on the index, because tz_convert needs an aware index first
Correct answer
-
A
Calling agg twice, since the second call renames the resulting columns
-
B
Named aggregation, with keywords mapping each name to a column and func
Correct answer
-
C
Passing a dictionary of column names to functions, then renaming afterwards
-
D
Passing a list of function names, which yields already-named columns
-
A
They are treated as unknown, so every NULL row survives in the resulting output
-
B
They abort the query, because set operators reject NULL values in any column
-
C
They are duplicated, since set operators never collapse duplicate NULLs
-
D
They are treated as equal, so the NULL row is removed from the difference
Correct answer
-
A
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, which also includes rows tied on day
Correct answer
-
B
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, counting only physical rows read
-
C
RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, which totals the whole partition
-
D
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING, a reverse running total by default
-
A
An error, because dividing two integers requires an explicit CAST in standard SQL
-
B
3, because integer division truncates; cast one operand to numeric to get 3.5
Correct answer
-
C
3.5, because SQL always performs division in floating point internally
-
D
4, because SQL rounds the exact quotient half up when both operands are ints
-
A
Every row whose email appears more than once in the table, one row per duplicate
-
B
One row per distinct email, including those that appear exactly once in users
-
C
One row per email, with the count replaced by the number of distinct duplicates
-
D
One row per duplicated email, with the number of occurrences in the count column
Correct answer
-
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