How to draw a triangle

In this topic, you will learn how to draw a triangle using turtle graphics.

Follow the instructions below to draw a triangle.

INSTRUCTIONS:

In the IDE to the right, you can see the lines that have forward‘, ‘right‘, forward, ‘right‘ and forward? Let’s add the following numbers into the brackets:

  1. Line 4: 1st Forward: add 100 i.e. turtle.forward(100)
  2. Line 5: Right: add –120
  3. Line 6: Forward: add 100 again
  4. Line 7: Right: add –120 again
  5. Line 8: Forward: add 100 again
  6. Click the Run button

That is one way of drawing a triangle.

The line turtle.forward draws a line the length of whatever number is in its brackets. Meanwhile, the turtle.left and turtle.right turns the arrow the number of degrees that is in-between its brackets. 

For our triangle the length is 100 and the arrows turn -120 degrees (but for our maths boffs, the angle inside the triangle is 60 degrees.)