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
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
Explanation: An Axes is one plot area; the Figure is the whole canvas and Axis is a single x or y ruler.
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()
Explanation: `plt.subplots()` returns the Figure and Axes so you can call methods on them explicitly.
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
Explanation: SVG is a vector format, so it scales without blurring.
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
Explanation: Colour-blind readers may not distinguish them; add markers, labels or use a safe palette.
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.
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
Explanation: Seaborn's barplot uses the mean as its estimator and adds an error bar by default.
MatplotlibMedium
Which formatter gives compact, non-repetitive multi-level date labels automatically?
amdates.ConciseDateFormatter
bticker.PercentFormatter
cmdates.DayLocator
dticker.NullFormatter
Explanation: ConciseDateFormatter shows the year once and months or days beneath it.
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
Explanation: Without a shared scale, panels with very different values can look deceptively similar.
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.
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
Explanation: Strings are treated as categories; real datetimes give correct spacing and let date locators work.