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
PandasMedium
What does `df.groupby('city')['sales'].sum()` return?
aA Series indexed by city
bA DataFrame
cA list
dA dict
Explanation: Selecting one column after groupby gives a Series.
Machine LearningEasy
K-Means is an example of…
aUnsupervised learning
bSupervised learning
cReinforcement learning
dDeep learning
Explanation: K-Means clusters without labels.
DjangoMedium
To avoid N+1 queries on a ForeignKey use…
aselect_related
bprefetch_related
conly()
dvalues()
Explanation: select_related does a SQL JOIN for FK/OneToOne.
Large Language ModelsEasy
An assistant confidently states a refund policy that does not exist. This is called…
aA hallucination
bA timeout
cOverfitting
dA rate limit
Explanation: A hallucination is fluent output that is not grounded in fact; grounding answers in retrieved sources reduces it.
Artificial IntelligenceMedium
With this heuristic, A* on a weighted graph behaves exactly like which algorithm?
h = lambda node: 0
path, cost = a_star(graph, start, goal, h)
aUniform-cost search (Dijkstra)
bDepth-first search
cGreedy best-first search
dBidirectional search
Explanation: With h = 0 the priority becomes just g(n), which is exactly uniform-cost search.
APIsMedium
Which HTTP method is NOT idempotent by definition?
aPUT
bDELETE
cGET
dPOST
Explanation: Repeating a POST can create duplicates; PUT, DELETE and GET leave the same state however often they are repeated.
Data ScienceMedium
Why should the API call below include `timeout=10`?
resp = requests.get(url, params={"page": 1}, timeout=10)
resp.raise_for_status()
aIt limits the response to 10 records
bIt retries the request 10 times
cIt caches the result for 10 seconds
dIt stops the request waiting forever on an unresponsive server
Explanation: Without a timeout, requests can hang indefinitely; the timeout raises an error instead.
Deep LearningMedium
What does this code print?
import torch
x = torch.tensor(3.0, requires_grad=True)
y = x ** 2 + 4 * x
y.backward()
print(x.grad)
atensor(21.)
btensor(10.)
ctensor(6.)
dNone
Explanation: dy/dx = 2x + 4, which equals 10 at x = 3.
DjangoMedium
Why redirect after a successful POST instead of rendering a template?
aRedirects are faster
bTemplates cannot be rendered after POST
cIt prevents the form being resubmitted when the user refreshes
dDjango requires it for CSRF
Explanation: The Post/Redirect/Get pattern leaves the browser on a GET page, so refresh doesn't repeat the POST.
ExcelMedium
In the formula below, what role does the `*` play?
=FILTER(Sales[Invoice], (Sales[State]="Rajasthan")*(Sales[Taxable]>50000), "None")
aIt multiplies the invoice values
bIt joins the two text conditions
cIt acts as a logical AND between the two conditions, row by row
dIt is a wildcard for any state
Explanation: Multiplying two TRUE/FALSE arrays gives 1 only when both are TRUE, which is the array equivalent of AND.
Git & GitHubMedium
What does this sequence do?
git reset --soft HEAD~3
git commit -m "Add GST report"
aDeletes the last three commits and their changes
bReverts three commits on the remote
cSquashes the last three commits into one, keeping all changes
dCreates three new branches
Explanation: A soft reset moves the branch back but keeps the changes staged, so one new commit replaces the three.
Large Language ModelsMedium
What is the main risk in this code?
args = json.loads(call.function.arguments)
return db.get_order(args['order_id'])
ajson.loads is slow
bThe model may request an order that belongs to another user; authorisation is not checked
cOrder IDs must be integers
dTool calls cannot return dicts
Explanation: Tool arguments are untrusted input, so the code must verify the user is allowed to access that order.
Machine LearningMedium
What does this code keep?
pca = PCA(n_components=0.95)
Z = pca.fit_transform(X_scaled)
aExactly 95 components
bEnough components to explain 95% of the variance
cThe 95% of rows with least noise
dComponents with variance above 0.95
Explanation: A float between 0 and 1 tells PCA to keep the smallest number of components reaching that explained-variance share.
MatplotlibMedium
What will the y-axis tick for 2500000 display?
from matplotlib.ticker import FuncFormatter
ax.yaxis.set_major_formatter(FuncFormatter(lambda x, pos: f'₹{x/1e5:.0f}L'))
a₹2500000
b₹25L
c₹2.5L
d₹25Cr
Explanation: 2500000 / 100000 = 25, formatted with no decimals and an L suffix.
NumPyMedium
What does this print?
a = np.array([[1, 2, 3],
[4, 5, 6]])
print(a.sum(axis=0))
a[6 15]
b[5 7 9]
c21
d[[5 7 9]]
Explanation: axis=0 collapses the rows, giving one sum per column.