Question bank

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

PandasMedium
What does `df.groupby('city')['sales'].sum()` return?
aA Series indexed by city
bA DataFrame
cA list
dA dict
Machine LearningEasy
K-Means is an example of…
aUnsupervised learning
bSupervised learning
cReinforcement learning
dDeep learning
DjangoMedium
To avoid N+1 queries on a ForeignKey use…
aselect_related
bprefetch_related
conly()
dvalues()
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
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
APIsMedium
Which HTTP method is NOT idempotent by definition?
aPUT
bDELETE
cGET
dPOST
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
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
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
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
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
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
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
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
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]]