Python · Module 9
Answers and explanations · Charts that answer a question
Compare these references after your own attempt. You can read them at any time; they do not record a live model or vendor run.
Module 9
The bar heights are 80, 70 and 30, with minutes on a zero-based axis. Exact labels and a synthetic-data title make the display easy to interpret. The image must still be visually inspected.
# Reference answer. Attempt the exercise first.
# Profile: Charts · Matplotlib
import matplotlib.pyplot as plt
topics = ["Python", "Data", "Charts"]
minutes = [80, 70, 30]
fig, ax = plt.subplots(figsize=(6, 3.5), layout="constrained")
ax.bar(topics, minutes, color=["#2563eb", "#0d9488", "#d97706"])
ax.set(title="Practice time by topic (synthetic sessions)",
xlabel="Topic", ylabel="Minutes", ylim=(0, 90))
ax.spines[["top", "right"]].set_visible(False)
for topic, value in zip(topics, minutes):
ax.text(topic, value + 2, str(value), ha="center")
fig.savefig("practice_minutes.png", dpi=160)
# The lab captures the chart and offers a download. Locally, open the PNG.
# For an interactive local window, optionally call plt.show() afterward.
# Text alternative: Python has 80 minutes, Data 70, Charts 30.
# These synthetic recorded durations do not measure learning gains.
Exit-check guide: A bar chart compares category totals. A truncated baseline can exaggerate their difference. Execution alone does not check clipping or readability. Practice time cannot establish learning gains or causation.