Chapter 1 · Section 5 practice

Matplotlib

Work from question 1 to 10. Edit your Python box, click Run Code, review the result, then click Submit attempt. Reference answers unlock after all ten attempts are submitted. This records completion, not correctness. Each box runs independently. Progress is saved in this browser.

Submitted: 0 / 10

1. Complete a title

Warm-up. Run this chart after adding the title Daily customers and a show call. Print “Line chart displayed”.

Write your answer, then run it.

2. Label units

Warm-up. Make a line chart for days [1, 2, 3] and revenue [3200, 3500, 3300]. Label axes Day and Revenue (HK$/day). Print “Units labelled”.

Write your answer, then run it.

3. Compare categories

Warm-up. Draw bars for Tea and Coffee with counts [30, 20]. Add labels and print the larger category.

Write your answer, then run it.

4. Show delivery spread

Build your skills. Draw a histogram of the supplied times using four bins. Label both axes and print the number of observations.

Write your answer, then run it.

5. Inspect an association

Build your skills. Draw a scatter plot of spend [100, 200, 300] and orders [80, 100, 110]. Add a comment explaining why the plot alone cannot prove causation. Print “Association is not causation”.

Write your answer, then run it.

6. Plot a labelled Series

Build your skills. Use a Series method to draw a bar chart of the supplied dish revenues. Keep labels horizontal and print the largest dish.

Write your answer, then run it.

7. Change histogram detail

Build your skills. Draw the delivery histogram with three bins, then six bins, in separate figures. Label both charts and print “Same data, different bins”.

Write your answer, then run it.

8. Choose a suitable chart

Challenge. For unordered dishes [Wonton, Char Siu, Milk Tea], select a chart to compare revenues [3570, 6380, 3920]. Draw it, then print your chart type and explain the choice in a comment.

Write your answer, then run it.

9. Plot a calculated quantity

Challenge. Compute daily revenues from counts [80, 90, 100] and a fixed HK$40 bill. Plot against Mon, Tue, Wed. Print the total and explain the trend limitation.

Write your answer, then run it.

10. Revenue is not profit

Challenge. Plot dish revenues [3570, 6380, 3920] as bars with a zero baseline. Print the highest-revenue dish and add two comments: one supported conclusion and one claim the data cannot support.

Write your answer, then run it.

Reference answers are locked until all 10 attempts are submitted.