Question bank

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

MatplotlibEasy
In Matplotlib, what does a single `Axes` object represent?
aThe x-axis ruler only
bOne plotting panel with its own x and y axis
cThe entire saved image
dA colour map
MatplotlibEasy
Which call is the recommended way to create a figure and one Axes in object-oriented style?
aplt.figure().plot()
bplt.axes_create()
cfig, ax = plt.subplots()
dax = plt.Axes()
MatplotlibEasy
Which file format is best for a chart that must stay crisp at any zoom level on a website?
aSVG
bJPG
cBMP
dLow-DPI PNG
MatplotlibEasy
Why should you avoid using only red vs green to separate profit and loss series?
aMatplotlib cannot draw red
bGreen lines are slower to render
cIt increases file size
dMany readers have red-green colour vision deficiency
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
MatplotlibMedium
By default, what do the bar heights in `sns.barplot(data=df, x='city', y='sales')` show?
aThe sum of sales per city
bThe count of rows per city
cThe mean of sales per city with a confidence interval
dThe median of sales
MatplotlibMedium
Which formatter gives compact, non-repetitive multi-level date labels automatically?
amdates.ConciseDateFormatter
bticker.PercentFormatter
cmdates.DayLocator
dticker.NullFormatter
MatplotlibMedium
Why is `sharey=True` important in a small-multiples dashboard?
aIt makes the figure render faster
bIt hides the y-axis completely
cIt lets seaborn compute confidence intervals
dIt puts every panel on the same scale so heights are comparable
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
MatplotlibHard
You plot daily sales where the date column holds strings like '05-04-2025'. Ticks are crowded and the spacing ignores missing days. What is the best fix?
aRotate the labels 90 degrees
bConvert with pd.to_datetime(col, dayfirst=True) and sort before plotting
cUse a bar chart instead
dSet plt.xticks([]) to hide labels