Fun with Flags – Part 1: flags and turtles

Step 1 – Drawing on the screen

To draw shapes in Python we need to use a turtle.

Code helper image
  1. Type this code into the code window:  from turtle import *

    Don't forget the * at the end – it's important

  2. Press Enter to get on to a new line
  3. Now type:  forward(100)

This code tells the turtle to move forward 100 steps.

The first line (the import line) is super important to include. Python can deal with turtles, but needs to bring in a new set of instructions before it can deal with them. That's what the import does.

REALLY IMPORTANT: every command word (like forward) in Python must be in all lower case letters. No capitals. Ever.

IMPORTANT: when you save your file DO NOT CALL IT turtle. This will cause an error and your code won't run.

Turtle imageSave the program

Before we can check the program works, we need to save it. You have to save every time you make a change.

  1. Click File > Save As

    IMPORTANT: make sure you're saving in your OneDrive

  2. Call the program something like  flags

    IMPORTANT: DO NOT CALL IT turtle. This will cause an error and your code won't run.

  3. Press Save

    Now let's run the program:

  4. Click Run at the top and choose Run Module

The program should run and look like the screenshot. If it comes up with an error, check your code and then run it again.

Why Turtles?
The first computer controlled robots for education were invented in the 1940s. They could move around using three wheels. A see-through plastic shell was put over the robots, which made them look a bit like a turtle. The first turtles were nicknamed Elmer and Elsie.

We don't need to give our turtle a name, but ever since then any form of movable drawing object has usually been called a "turtle".

You might have used a toy turtle in primary school perhaps.