The Handbook
You don’t need to read it all at once. It’s here so you can look things up when you’re stuck. Think of it like a recipe book: when you want to make something, you flip to the right page.
What is Python?
Python is a language you use to tell a computer what to do. You write instructions in a file, and the computer follows them one line at a time, from top to bottom.
What is pygame?
pygame is a toolbox for Python that lets you make games and moving pictures on the screen — windows, shapes, colours, and things that move around. We’ll use it for your evolution sim.
How to run your code
- Save your code in a file that ends in
.py— for examplemy_program.py - Run it (your grown-up can show you how the first time)
- Watch what happens!
The golden rule
Type it. Run it. Break it. Fix it.
The best way to learn is to type the examples yourself (don’t just read them), run them, then change a number or a word and see what happens. Breaking things and fixing them is how you learn. Every programmer does it — even the ones who’ve been doing it for 30 years.
Mistakes are normal. When the computer shows you a red error message, it’s not telling you off. It’s trying to help you find the problem. We have a whole page about reading those messages.
The map — what’s in each page
| Page | What it teaches |
|---|---|
| 1. The Basics | Printing, comments, variables, constants, f-strings |
| 2. Making Choices | if, else, elif, and comparing things |
| 3. Lists | Lists: making them, adding to them, going through them |
| 3b. Dictionaries | Dictionaries: storing values with labels you look up |
| 4. Loops | for loops and while loops (doing things over and over) |
| 5. Randomness | Random numbers and choices (super important for evolution!) |
| 6. Functions | Functions: little machines you build once and reuse |
| 7. Handling Errors | try / except: what to do when things go wrong |
| 8. Classes & Objects | Classes and objects — building your own Creature! |
| 9. Bringing It Together | A tiny creature world using everything above |
| 10. pygame Basics | Making a window with moving shapes |
| 11. Cheat Sheet | A quick reminder of everything on one page |
A few words you’ll see a lot
- Code — the instructions you write.
- Run — make the computer follow your code.
- Output — what your code shows on the screen.
- Bug — a mistake in your code.
- Variable — a labelled box that holds a value (more on the next page!).
Ready? Open 1. The Basics and let’s go. 🚀