A farm market HTML report with two charts and a sentence
Write code · Challenge · §10.4 Assembling an HTML report
There is a line chart line_fig and a bar chart of totals bar_fig, made from the monthly boxes sold at two market stalls, Orchard and Greens, from March to August. Put both charts in one HTML document and save it as market.html in a folder report.
The body of the document has, in order, the main heading (h1) Farm market report, the paragraph (p) From March to August, Orchard sold 1,520 boxes and Greens sold 1,210 boxes., the heading (h2) 1. Monthly sales with the line chart, and the heading (h2) 2. Total sales with the bar chart. Take the two numbers in the paragraph from totals and add thousands separators.
So that the file opens without the internet, put Plotly.js only in the first chart so that it is inside the file once. Grading changes the box counts and saves the file again.
Starter code
from pathlib import Path
import pandas as pd
import plotly.express as px
dates = pd.date_range("2026-03-01", periods=6, freq="MS")
market = pd.DataFrame({
"date": list(dates) * 2,
"stall": ["Orchard"] * 6 + ["Greens"] * 6,
"boxes": [180, 210, 260, 240, 300, 330, 150, 170, 190, 230, 250, 220],
})
totals = market.groupby("stall", as_index=False)["boxes"].sum()
line_fig = px.line(market, x="date", y="boxes", color="stall", markers=True, title="Boxes sold per month")
bar_fig = px.bar(totals, x="stall", y="boxes", color="stall", text_auto=",", title="Total boxes, March to August")
# Write your code hereSolve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.