Fun with Flags – Part 2: more flags

Step 6 – Drawing triangles

So far we've only used the turtle to draw squares and rectangles. Turtles are good at quadlaterals.

But they can draw other shapes as well.

Let's try and draw a triangle...

Code helper image
  1. Start a new Python file – click File > New file
  2. Use the screenshot to write code to draw a basic triangle

    This triangle won't be filled in. That's OK

  3. Run your code to test it out
  4. Add begin_fill() and end_fill() to fill the triangle
  5. Run your code again to see if it fills in right
  6. Try changing the colour of the triangle

That should draw an equilateral triangle. You've come across those in maths.

The problem with triangles...

The difficulty with triangles is getting the angles to turn right.

With quadrilaterals it was easy. All turns were 90°.

With triangles most of the turns you're going to need will be 60° or 120°. That's because the angles on a straight line always add up to 180°. You should also remember from maths that the angles inside a triangle always add up to 180° as well.

The angle to turn in a triangle can be really tricky to get right.

It can also be hard to work out how many steps forward to move the turtle at times. That's OK – I'll always help you out with the code until you get the right sort of idea.