Fun with Flags – Part 2: more flags

Step 4 – Turtle challenge 2.3

Not every flag is just made up of stripes like the Lithuanian flag or the French tricolour.

Some flags are a little trickier to draw.

Flag of BeninProblem – the flag of Benin

The flag of Benin has a vertical stripe and then two horizontal strikes.

That makes it a bit harder to draw. Until you work out a shortcut...

The basic colours here are probably:

Remember, the base flag is 180 steps wide and 120 steps tall.

I'm sure you could give this a go knowing what you already do.

  1. Write code to draw the flag of Benin

    Use the notes above and what you already know to help

  2. Run your code to test it out
  3. If it's not quite right the first time, make some changes until you get it right.

Did you manage it?

Benin is a country in West Africa. It's west of Nigeria on the coast. It used to be part of the French colonial empire and became independent in 1960.

Shortcut method

There's a shortcut method here that would probably make the code quicker. You might have already figured it out.

Try this sequence:

  1. Draw a flag like the Ukrainian flag, using a gold and red section

    Each stripe with be 180 steps wide (the full width of the flag) and 60 steps tall (half the height)

  2. Change the colour to darkgreen
  3. Draw a dark green shape about 60 steps wide over the top of part of the first flag you drew

You'll need to be a bit clever when you draw the green section. It will depend on where your turtle finished up with the yellow and red stripes

You'll notice that this code doesn't produce a perfect flag. The green bar wants to be a little bit wider and you might have a small red line at the bottom. To get rid of the red line, just add code to end up back in the bottom left corner.