Project 7
Happy Birthday
Real-world events like counting how many babies are born means collecting lots of data. Sometimes, this can take too long. Creating a simulation helps you to understand an event in less time. A simulation is a pretend version of the real event. In this project, you will create a maternity ward simulation — a model of a hospital room where babies are born and celebrate their “zero birthdays.”
Instead of taking nine months for a baby to arrive, this simulation makes a pretend newborn boy or girl by clicking a button. Then, using the repeat command, you can make hundreds of babies (or more) to represent all the births in a state or country. Using the simulation, you can quickly look at the distribution of births, meaning how many boys and girls are born in a large population of babies. Say “Happy Birthday!”
Brainstorm
The Happy Birthday simulation does not have to feature babies being born. Consider simulating the birth of any creature, particularly those that produce only one offspring at a time:
- Elephants
- Whales
- Hippos
- Gorillas
… or fantasy creatures you invent!
Also consider alternatives for where the “baby” is born:
- A meadow or forest
- A zoo or circus
- The ocean
- A space station!
You can even change the entire project to represent any other two-outcome scenario, such as flipping a coin (heads or tails), evaluating the state of a radioactive atom (decayed or not decayed), lighting a lamp (on or off), or monitoring the health of Schrödinger’s cat (dead ...
Get Coding For Kids For Dummies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.