Fun with Flags – Part 1: flags and turtles

Step 7 – Flags with two colours

Now that we know how to make the turtle draw shapes with colours, let's go for something a bit more challenging.

Several countries have flags with just two colours on them. So one of those would be a good starting point.

Flag of UkraineProblem – the flag of Ukraine

As this is being written you see a lot of Ukrainian flags flying all over the world.

This is quite an easy flag to draw – it's two rectangles joined together.

As our basic flag shape is 180 steps wide and 120 steps high, we'll need to cut it in half across the middle.

That means we'll need two rectangles of different colours. Each rectangle will need to be 180 pixels wide and 60 pixels high – half of 120.

  1. The code on the right shows you how to create one rectangle of the right size. It also gives you the two colour names. Use it to see if you can draw a Ukrainian flag

    Code helper imageYou'll probably make a mistake here. That's OK – there's a solution at the bottom if you can't get it right

  2. Run your code to test it out
  3. If it's not quite right the first time (it probably won't be!), make some changes until you get it right. Use the solution below if you're really stuck

One of the keys here is getting the turtle facing in the right direction.

Don't worry if it takes a while to get this working. Once you get the right idea and understand why you made the mistake it'll make drawing other flags much easier.