Randomness
Is this dice fair?
π School maths Β· Years 7β8Probability β Use relative frequency from many trials to judge fairness.Maths by year β
The Case. You're playing Snakes and Ladders and it feels like you NEVER roll a six, while your brother rolls them all day. Is the dice actually unfair, or is it just bad luck? You can't roll it a thousand times by hand β but the computer can in a blink. This is how scientists check whether something is really happening or just chance.
Your tools. numpy rolls the dice for us in an instant with np.random.randint. A slider sets how many rolls.
Investigate. Drag the rolls_count slider above the code. A fair dice makes all six bars roughly equal β and the more you roll, the clearer it gets.
- Slide from 20 up to 5000 β watch the bars even out. That's more data = clearer truth.
- Each drag re-rolls, so the bars wobble a little β that's real randomness at work.
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
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.