Counting with colour
A rainbow of favorites
π School maths Β· Years 2β3Statistics β Count into categories and read a bar chart / pictogram.Maths by year β
The Case. Peek in the fruit bowl: maybe 3 apples, 5 bananas and a big bunch of grapes. Which fruit do you have the most of? Shops make this exact kind of picture to see which snacks sell best and what to order more of β let's make our own with colourful bars.
Your tools. matplotlib lets you pick a colour for every bar.
Investigate. Press Run and see which fruit wins. Then change the fruits and numbers.
- Which bar is the tallest? That's the fruit you have the most of.
- Try counting something else β your toys, or crayons by colour.
your_code.py
Starting Pythonβ¦
The Reveal
Starting Pythonβ¦ (first time only β a few seconds)
ποΈ Detective's notes
Bundles your findings, chart and code into one PDF you can keep, print or hand in.
π§© How this code works
The tools it uses
- Matplotlib β your crayon box β it turns numbers into charts and pictures.
What this one does
- β’ It draws a bar chart β great for comparing amounts.
How to read it, top to bottom
- 1. Import β bring in the tools (listed above).
- 2. The data β the lists and numbers near the top. These are the bits you change.
- 3. The work β a little maths, or a loop that repeats a step.
- 4. Show it β
print(...)writes words;plt.show()draws the picture.
Use it for your own problems
- Change the numbers at the top and press Run β nothing breaks, so experiment!
- Ask your own version of the question β swap in your family, your scores, your week.
- The same tools work on any numbers β that's the superpower you're learning.