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
DjangoHard
How many database queries does this run?
qs = Post.objects.filter(published=True)
qs = qs.order_by('-created')
for p in qs[:5]:
print(p.title)
aOne, when the loop starts iterating
bTwo, one per queryset line
cThree
dSix, one per post plus one
Explanation: Querysets are lazy: filtering and slicing only build the SQL, which is sent once when the results are first needed.
Large Language ModelsHard
This sometimes raises a JSONDecodeError because the model adds a sentence before the JSON. Best fix?
data = json.loads(response.text)
aAsk for a defined JSON schema using the provider's structured-output mode, then validate and retry on failure
bRaise the temperature
cStrip everything before the first '{' and hope for the best
dSwitch to a larger context window
Explanation: Schema-guided output plus validation is far more reliable than parsing free text; keep a retry for the rare invalid response.
Artificial IntelligenceHard
A routing heuristic uses straight-line distance multiplied by 1.5 to allow for detours. Why can A* now return a sub-optimal route?
aMultiplication makes the priority queue slower
bThe heuristic becomes negative for nearby nodes
cThe heuristic may overestimate the remaining cost, so it is no longer admissible
dA* only accepts integer heuristics
Explanation: Optimality requires an admissible heuristic that never overestimates; scaling it up breaks that guarantee.
APIsHard
Why is cursor (keyset) pagination preferred over large offsets on big tables?
aCursors allow jumping to any page number
bOffsets are not supported by SQL
cCursors are easier to implement in the client
d`WHERE id > last_id` uses an index, while big OFFSETs scan and discard many rows
Explanation: Deep offsets get slower and unstable as data changes; keyset pagination stays fast and consistent.
Data ScienceHard
You SHA-256 hash customer mobile numbers without a salt and share the hashes. Why is this weak protection?
aSHA-256 output is reversible with a decryption key
bHashes are longer than the original numbers
cHashing changes the data type to float
dThe space of 10-digit mobile numbers is small enough to hash every possibility and match
Explanation: Unsalted hashes of low-variety data can be brute-forced; a secret salt blocks that lookup attack.
Deep LearningHard
Why are attention scores divided by the square root of the key dimension?
aTo stop large dot products from pushing softmax into saturated regions with tiny gradients
bTo make attention weights sum to 1
cTo reduce memory usage from quadratic to linear
dTo add positional information to the tokens
Explanation: Dot products grow with dimension; scaling keeps their variance stable so softmax stays trainable. Softmax itself ensures weights sum to 1.
DjangoHard
How many queries does this loop run for 50 orders (no other optimisation)?
for o in Order.objects.all():
print(len(o.items.all()))
a1
b2
c51
d100
Explanation: One query for the orders plus one per order for its items — the N+1 problem; `prefetch_related('items')` makes it 2.
ExcelHard
In Power Query, a text column of dates like `13/04/2026` errors when you change its type to Date on a US-English machine. What is the correct fix?
aRemove the error rows
bSplit the column and rebuild the date
cReplace the slashes with hyphens first
dUse Change Type With Locale and choose Date, English (India)
Explanation: Locale tells Power Query the values are dd/mm/yyyy, so 13 is read as the day rather than an invalid month.
Git & GitHubHard
Roughly how many test steps does `git bisect` need to find a bad commit among about 1,000 commits?
aAbout 10
bAbout 100
cAbout 500
dAbout 1,000
Explanation: Bisect halves the range each step, so log2(1000) is roughly 10 steps.
Large Language ModelsHard
Why does this agent loop include a step limit?
for _ in range(MAX_STEPS):
msg = llm(messages, tools=TOOLS)
if not msg.tool_calls:
return msg.content
aAPIs reject more than six calls
bTo prevent runaway loops that waste cost or repeat actions endlessly
cIt improves the model's accuracy
dTo keep the context window empty
Explanation: Capping steps bounds cost, latency and damage if the model keeps calling tools without finishing.
Machine LearningHard
In gradient boosting, lowering `learning_rate` from 0.3 to 0.03 usually requires…
aMore boosting iterations to reach similar performance
bFewer iterations
cRemoving early stopping
dDeeper trees only
Explanation: Each tree contributes less, so more trees are needed; the trade-off often improves generalisation.
MatplotlibHard
A Django view generates a chart on every request and memory keeps growing. What is the most likely fix?
def chart(request):
fig, ax = plt.subplots()
ax.plot(get_data())
buf = io.BytesIO()
fig.savefig(buf, format='png')
return HttpResponse(buf.getvalue(), content_type='image/png')
aCall plt.close(fig) after saving
bIncrease the dpi
cUse plt.show() instead of savefig
dSwitch to JPG
Explanation: Pyplot keeps references to open figures; closing each one releases its memory.
NumPyHard
What does this code print?
x = np.array([100, 120], dtype=np.int8)
print(x + x)
a[200 240]
b[-56 -16]
cOverflowError is raised
d[127 127]
Explanation: int8 array arithmetic wraps around silently: 200 - 256 = -56 and 240 - 256 = -16.
PandasHard
What does this produce?
g = df.groupby(["branch", "category"])["amount"].sum()
t = g.unstack("category", fill_value=0)
aA long Series with a 3-level index
bA DataFrame with branches as rows and categories as columns
cA DataFrame with categories as rows and branches as columns
dAn error because unstack needs a DataFrame
Explanation: unstack moves the 'category' index level into columns, leaving branch as the row index.
Power BIHard
An RLS role filters `Store[Region] = "Vidarbha"`, and a user assigned to that role is also a Member of the workspace. What do they see?
aOnly Vidarbha rows, because RLS always wins
bNo data at all, because the two permissions conflict
cAll rows — RLS is not applied to workspace Admins, Members or Contributors
dOnly Vidarbha rows in reports but all rows in the model
Explanation: RLS applies to Viewers and app consumers; users with edit rights on the workspace bypass it, so restricted users must be Viewers.