This project introduces for loops through a fun turtle race game. Loops are used to draw the race track and to make the turtles move a random number of steps each turn. A group of children can each pick a turtle, the one that gets the furthest is the winner.
This project uses Python 3. We recommend using trinket to write Python online. This project contains the following Trinkets:
There is also a trinket containing a sample solution to the challenges:
This project can be completed offline if preferred. You can access the project resources by clicking the ‘Project Materials’ link for this project. This link contains a ‘Project Resources’ section, which includes resources that children will need to complete this project offline. Make sure that each child has access to a copy of these resources. This section includes the following files:
You can also find a completed version of this project’s challenges in the ‘Volunteer Resources’ section, which contains:
(All of the resources above are also downloadable as project and volunteer
- For loops;
- Python turtle graphics
This project covers elements from the following strands of the Raspberry Pi Digital Making Curriculum:
- More lines - changing the number of times a loop repeats;
- Race times - adding more turtles, includes adding code inside a loop;
- Do a twirl - make turtles spin round at the start by writing new for loops;
- Dashed lines - change solid lines into dashed lines, requires a nested loop.
Frequently Asked Questions
- Children may need reminding about the colon
:at the end of a
for, it’s easy to omit.
- Incorrect indentation is a common problem when writing loops.
- Children may need reminding that there shouldn’t be a space in the code
- Children should make sure that they write ‘color’ and ‘center’ using the American spelling.