Ages 10+ · Coding · Python
Turtle drawing
1 for i in range(4): 2 t.forward(100) 3 t.right(90) Four sides and four turns, in three lines. The big idea A loop draws the sides, and the turns share one full circle of degrees.
How it works Forward moves the turtle ahead and draws a line. Right turns the turtle on the spot, in degrees.
Ninety degrees is a quarter circle, like the corner of a book.
A loop draws the sides. The number in range is the number of sides.
Walking all the way round is one full circle, 360 degrees, and the turns share it out: each turn is 360 divided by the number of sides.
The shape • triangle: 3 sides • square: 4 sides • pentagon: 5 sides • hexagon: 6 sides Each turn • 120 degrees • 90 degrees • 72 degrees • 60 degrees Sides and turns. Runs of the loop 0 1 2 3 4 5 6 3 Triangle 4 Square 5 Pentagon 6 Hexagon runs The loop runs once for each side. Example 1: The square Tilly draws forward 100 and turns right 90, four times, with range of four. The four turns share the full circle: 4 * 90 = 360. The line closes into a square. Example 2: The triangle A triangle has three sides, so the loop is range of three. Each turn is 360 divided by 3: 360 / 3 = 120. Tilly turns 120 degrees and draws a closed triangle. Example 3: The hexagon A hexagon has six sides, so the loop is range of six. Each turn is 360 divided by 6: 360 / 6 = 60. Tilly turns 60 degrees six times, and the six sides close. Example 4: The hook Mina runs range of three but keeps the turn of ninety. Three turns of 90 only make 3 * 90 = 270, not 360. The line never closes, so Tilly draws a hook. The mix-up to fix: change the turn to 120, because a triangle has three turns that share 360. Example 5: The pentagon A pentagon has five equal sides, so the loop is range of five. Each turn is 360 divided by 5: 360 / 5 = 72. Tilly turns 72 degrees five times. Words to know degrees How big a turn is. A full circle is 360. forward Moves the turtle ahead and draws a line. right Turns the turtle on the spot. loop Repeats forward and turn, once for each side. full circle 360 degrees, shared out by the turns. Watch out A turn of 90 for a triangle leaves a hook. The turn must be 360 divided by the number of sides. A turn command spins the turtle on the spot. Forward is what draws the line. The number in range is the number of sides, because the loop draws one side each time. The rule of 360 divided by the sides is for shapes with equal sides. Try it What is each turn of a square? What is each turn of a triangle? A loop of range(6) with a turn of 60 draws which shape? A shape has 8 equal sides. What is each turn? True or false: with more sides, each turn is smaller. Answers: 1. 90 degrees · 2. 120 degrees · 3. A hexagon · 4. 45 degrees · 5. True
Try at home Ask a grown-up to call out: walk four big steps, then turn a quarter turn, and repeat that four times. You will have walked a square! Then try a triangle, with a third of a turn each time, and mark your path with chalk if you can.
For grown-ups Play the Mission together: call out walk four big steps, then turn a quarter turn, and repeat four times so your child walks a square. Then try a triangle with a third of a turn each time, and mark the path with chalk if you can.