Your first case
Am I growing faster than my sister?
The Case. Every birthday you get measured against the doorframe, and this year you're sure you shot up. But did you really grow faster than your big sister did when she was your age? Feelings can trick us β so let's line up the real numbers and let a chart settle it, the same way doctors track how children grow.
Your tools. numpy is a row of boxes that holds numbers so you can do maths to all of them at once. matplotlib is your crayon box for charts.
Investigate. Press Run and read the chart: whose line climbs more steeply grew faster. np.diff tells us how many centimetres you grew each year.
- Change the numbers to your family's real heights.
- Look for the year the two lines cross β what happened?
Starting Pythonβ¦ (first time only β a few seconds)
Bundles your findings, chart and code into one PDF you can keep, print or hand in.
π§© How this code works
The tools it uses
- NumPy β a row of boxes that holds numbers, so you can do maths to all of them at once.
- Matplotlib β your crayon box β it turns numbers into charts and pictures.
What this one does
- β’ It draws a line chart β great for change over time.
- β’ It measures how much things change each step.
- β’ It finds the biggest value.
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.
Need a hint?
The steeper line grew faster. Try plt.plot(age[1:], np.diff(my_cm)) to chart the growth itself.