Question bank

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

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
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
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
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
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
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
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
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)
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
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
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
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
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]
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
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