Question bank
Pick an answer to see if you're right — with an explanation.
All topicsPythonSQL / MySQLData ScienceNumPyPandasMatplotlibMachine LearningDeep LearningArtificial IntelligenceLarge Language ModelsDjangoAPIsGit & GitHubPower BIExcelStatistics
PythonHard
Why use `functools.wraps` inside a decorator?
aIt copies the wrapped function's name, docstring and metadata onto the wrapper
bIt makes the wrapper run faster
cIt caches return values
dIt is required for decorators to accept arguments
Explanation: Without it, the decorated function reports the wrapper's name and loses its docstring, confusing debugging and tools.
SQL / MySQLHard
Two cashiers may sell the last box at the same time. What prevents overselling inside a transaction?
aSELECT ... FOR UPDATE before the UPDATE
bAdding DISTINCT to the SELECT
cUsing READ UNCOMMITTED isolation
dRunning the UPDATE twice
Explanation: FOR UPDATE locks the selected row so the second transaction waits until the first commits.
StatisticsHard
An analyst checks an A/B test every morning and stops as soon as p < 0.05. Why is this a problem?
aIt makes the test less sensitive
bZ-tests cannot be run more than once
cIt reduces the sample ratio
dRepeated peeking inflates the false-positive rate well above 5%
Explanation: Each look is another chance to cross the threshold by luck; fix the duration or use sequential methods.
PythonHard
What is printed?
fs = [lambda: i for i in range(3)]
print(fs[0]())
a2
b0
c1
dTypeError
Explanation: All three lambdas share the same `i`, which is 2 once the comprehension finishes; capture it with a default argument such as `lambda i=i: i`.
SQL / MySQLHard
Why do customers with no orders disappear from this result?
SELECT c.name, o.id
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.id
WHERE o.status = 'PAID';
aLEFT JOIN cannot be combined with WHERE
bThe WHERE test on the right table drops the NULL rows, so the join behaves like an INNER JOIN; move the condition into ON
cThe query is missing GROUP BY
dBecause `o.id` is selected
Explanation: Unmatched rows have NULL in every `o` column and `NULL = 'PAID'` is never true; putting the filter in the ON clause keeps those customers.
PandasHard
After `pd.concat([df1, df2])`, `df.loc[0]` returns two rows. Why?
aconcat always duplicates the first row
bBoth frames kept their original index labels; pass ignore_index=True to renumber
c`loc` always returns a DataFrame
dThe two frames have different columns
Explanation: concat stacks the frames without touching the index, so labels repeat; ignore_index=True (or reset_index(drop=True)) gives a fresh 0..n-1 index.
Machine LearningHard
As a model is made more flexible (deeper trees, more features), what usually happens?
aBoth bias and variance fall
bBias falls while variance rises
cBias rises while variance falls
dNeither changes
Explanation: A more flexible model fits the training data more closely (lower bias) but reacts more to the particular sample (higher variance).
DjangoHard
When should a project switch to a custom user model?
aOnly after real users exist in the database
bAt the start, before the first migration, by setting AUTH_USER_MODEL
cNever; Django forbids it
dAny time, it is a one-line change with no data impact
Explanation: Swapping the user model after migrations have run is painful, so define it and point AUTH_USER_MODEL at it before the first migrate.
Large Language ModelsHard
Even with temperature set to 0, the same prompt can return slightly different answers. Why?
aTemperature 0 is ignored by every provider
bServing-side factors such as batching, hardware floating-point differences and silent model updates make output non-deterministic
cThe prompt is re-tokenised at random
dBecause embeddings expire
Explanation: Temperature 0 makes sampling greedy but does not guarantee identical results across requests, so pin model versions and test with tolerance.
Artificial IntelligenceHard
Which change most reduces the risk of an agent taking a harmful, irreversible action?
aIncreasing the temperature so it explores more options
bRequiring human approval for write tools while read-only tools run automatically
cGiving it more tools so it always has an alternative
dEnlarging the context window
Explanation: Least privilege plus approval on irreversible actions limits damage far more than any prompt wording.
APIsHard
Why does this webhook check use `hmac.compare_digest` instead of `==`?
expected = hmac.new(secret, body, hashlib.sha256).hexdigest()
ok = hmac.compare_digest(expected, received)
aIt is faster than ==
bIt compares in constant time, preventing timing attacks
cIt also decodes Base64
d== cannot compare hex strings
Explanation: A normal comparison stops at the first differing character, leaking timing information an attacker can exploit.
Data ScienceHard
Revenue fell 10% while order count stayed flat. Using a KPI tree (revenue = orders x AOV), where should you investigate first?
aFootfall and app sessions
bConversion rate
cAverage order value: items per order and selling price after discounts
dNumber of stores opened
Explanation: With orders flat, the drop must come from the AOV branch of the tree.
Deep LearningHard
What shapes are printed?
import torch, torch.nn as nn
lstm = nn.LSTM(input_size=10, hidden_size=32, num_layers=2, batch_first=True)
x = torch.randn(4, 15, 10)
out, (h, c) = lstm(x)
print(out.shape, h.shape)
a(4, 15, 32) and (4, 2, 32)
b(15, 4, 32) and (2, 4, 32)
c(4, 15, 32) and (2, 4, 32)
d(4, 32) and (2, 32)
Explanation: `out` holds the top layer's state at every step in batch-first layout, while `h` is always (num_layers, batch, hidden).
DjangoHard
Which statement decrements stock safely even if two requests run at the same moment?
ap.stock = p.stock - 1; p.save()
bProduct.objects.filter(pk=p.pk).update(stock=F('stock') - 1)
cp.refresh_from_db(); p.stock -= 1; p.save()
dProduct.objects.get(pk=p.pk).stock -= 1
Explanation: F() makes the database compute `stock - 1` in a single UPDATE, avoiding a read-modify-write race.
ExcelHard
Your dashboard has three PivotTables from the same Table, but the State slicer filters only one of them. What fixes it?
aCopy and paste the slicer twice
bConvert the slicer into a Timeline
cRight-click the slicer, open Report Connections and tick all three PivotTables
dMove all three PivotTables onto the dashboard sheet
Explanation: A slicer controls only the pivot it was created from until the other pivots are linked via Report Connections.