Question bank

Pick an answer to see if you're right — with an explanation.

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
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
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%
PythonHard
What is printed?
fs = [lambda: i for i in range(3)]
print(fs[0]())
a2
b0
c1
dTypeError
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
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
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
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
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
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
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
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
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)
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
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