Python Turtle – Protractor Challenge

Python Turtle? Let’s Recap!

Looking at the following code can you explain the purpose of each Python Turtle instructions:

  • turtle.color(“red”)
  • turtle.forward(100)
  • turtle.right(90)
  • turtle.left(45)
  • turtle.penup()
  • turtle.pendown()
  • turtle.goto(0,0)
  • turtle.setHeading(45)

(X,Y) Coordinates?

The canvas we are drawing on (using Python Turtle) is 400 pixels wide by 400 pixels high.
Look at the canvas below to understand how (x,y) coordinates work:

Protractor Challenge:

A protractor is an instrument used in Maths when measuring or drawing angles.

Our challenge is to use Python to draw a protractor on screen, using all the graduations for a scale going from 0° to 180°.

To do so we will use an iterative algorithm based on the following flowchart:

Your task consists of using Python code to implement this flowchart using Python Turtle.

Extension Task #1

Improve the drawing of your protractor further by:

  • adding labels (e.g. 0°, 10°, etc.) next to each graduation,
  • adding smaller graduations (e.g. 5°, 15°, 25° etc. graduations).

Extension Task #2

Use a similar approach to draw an analogue clock using Python Turtle.

Share Button
Tagged with: ,