Lesson 3: Any shape
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version.
The 360 rule
- To draw a shape with
nequal sides, turn360 / ndegrees at each corner. - Square: 360 / 4 = 90. Triangle: 360 / 3 = 120.
Words for this lesson
| Word | Meaning |
|---|---|
| polygon | a closed shape with straight sides |
| hexagon | a polygon with 6 sides |
| variable | a name for a value, like sides = 6 |
Change one number
import turtle
sides = 5
for i in range(sides):
turtle.forward(80)
turtle.left(360 / sides)
- Change
sidesto 6, 8 or 10. The loop does the rest.
Difficulty 2/5 · 140 coins + a small bonus on first completion today
Draw a hexagon: 6 equal sides of 80 steps. Use a loop and the 360 rule.
Click Run to see the output here.
Difficulty 2/5 · 140 coins + a small bonus on first completion today
Draw an octagon (8 sides) with sides of 50 steps. A stop sign has this shape.
Click Run to see the output here.