Chapter 1

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

  1. Save your code in a file that ends in .py — for example my_program.py
  2. Run it (your grown-up can show you how the first time)
  3. 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

PageWhat it teaches
1. The BasicsPrinting, comments, variables, constants, f-strings
2. Making Choicesif, else, elif, and comparing things
3. ListsLists: making them, adding to them, going through them
3b. DictionariesDictionaries: storing values with labels you look up
4. Loopsfor loops and while loops (doing things over and over)
5. RandomnessRandom numbers and choices (super important for evolution!)
6. FunctionsFunctions: little machines you build once and reuse
7. Handling Errorstry / except: what to do when things go wrong
8. Classes & ObjectsClasses and objects — building your own Creature!
9. Bringing It TogetherA tiny creature world using everything above
10. pygame BasicsMaking a window with moving shapes
11. Cheat SheetA 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. 🚀