← Code

Python functions and events

Write your own functions, then use them to make a button and a game.

Start1. Read a program

Start from a working program

Read a longer program and change it without breaking it.

1Read a programNot started

Functions

Name steps, give them inputs and outputs, and keep them in modules.

2FunctionsNot started
3Functions with parametersNot started
4Functions that give answersNot started
5Functions that decideNot started

Put an if inside a function so it chooses its answer, then call it for every item in a list: decisions, lists and functions working together.

  1. Predict
  2. Run
  3. Investigate › Trace the decisions
  4. Investigate › Why a function?
  5. Investigate › Spot the bug
  6. Modify › Three colours
  7. Modify › Count the big ones
  8. Score bars
Start lesson
6ModulesNot started

Interaction

Events, and a button built from scratch.

Final challenge: Catch the turtle

Build a game that uses everything, then add power-ups. Two optional lessons go further.

9Catch the turtleNot started
10Power-upsNot started
11Control panel OptionalNot started
12Game levels OptionalNot started

Progress is saved in this browser only. Nothing is sent anywhere.

For teachers: Teacher guide (notes, answers, solutions, slides and worksheets)