Fun with Flags – Part 1: flags and turtles

Step 5 – Colouring a flag

Flags aren't blank. They use colours on them to tell them apart.

Some use other shapes and symbols on them. They're much harder to draw. We'll start with the easiest ex-flag in the world.

Flag of Libya (1957-2011)Problem – the flag of Libya (1957–2011)

From 1957 until 2011 the flag of Libya was green. It didn't have any symbols or other colours on it. It was just green.

No other national flag uses just one colour. So we'll start with this flag.

The first thing we need to do is learn how to get the turtle to draw coloured shapes.

There are a special set of colours we can use. Don't just make up your own colours – you have to use a colour that the turtle already knows.

Code helper image
  1. First we need to tell the turtle what colour to use. We do this using the command: color("forestgreen")

    IMPORTANT: this uses the American spelling of the word color

    There are lots of different colours you can use. We'll come back to those in the next step...

  2. Then we need to tell the turtle to colour the shape in. To do that we use the command: begin_fill()

    Be careful here: there are quotes and brackets and underscores to include. If you don't do it right you'll get an error message.

  3. Then draw the rectangle just as before
  4. Then we need to add the command end_fill()
  5. Run your code to check that it works

If you got an error, check that you dealt with the quotes, brackets and under_scores properly. And did you spell color the right way in your code?

Libya is a country in north Africa to the west of Egypt.
A revolution in 2011 led to a change in government and the flag has now changed – check the new flag out.

A Technical Problem

The old flag of Libya was a slightly different shape to most flags.

It was, technically, twice as wide as it was high. That means that if you're using a width of 180 steps, the flag should really be only 90 steps high.

Can you fix your flag to get it perfect?