Students see that the square they drew with eight lines can be written with three, using a loop, and find out how to change the count and the turn.
Core ideas this lesson introduces: Repeat a number of times needs Steps in order. How the ideas build
Open these in Waypoints Prepare with one click. To share a file another way, copy its address and paste it into Load URL, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.
Predict and Run 10 min · Investigate 10 min · Modify 8 min · Make 7 min
Open the lesson, run the first program and draw the triangle from the Modify step yourself. It takes about five minutes and you will meet the same surprise students do: the turn is 120 degrees, not 60.
On the slides at these points. Students can do the whole lesson on their own; these are for the room. In the deck, the Run, Modify and Make slides have the live playground in them (the tutorial link is the backup), and the notes above are in each slide's speaker notes.
Let students defend both sides. Copying wins when each step is different, when you will only ever do it once, or when a reader needs to see every step. The loop wins when the steps are the same and the count may change. Return to this after the staircase Make: did anyone choose copying, and why?
Think aloud: Python says there is a problem on line 3. I'm not going to guess. I read the line number, look at that line, and read the message slowly. It points at the colon after range. I put it back and run again. It worked, so the message told me where to look.
Here is a shape drawn by 3 lines of Python. By the end of the lesson you will write programs like it.
Run the 36-sided shape from the stretch task on the projector (for i in range(36): forward(20) right(10)) before anything else. Ask: how many lines of code do you think that took?
One volunteer is the turtle, standing in the middle facing the window. The class reads the loop aloud, one line at a time. The turtle obeys: 3 steps for forward(100), a quarter turn for right(90). Now try it with range(3) and right(120). Where does the turtle end up?
Papert designed the turtle so learners could play it. Walking the shape makes two things concrete: only the indented lines repeat, and a closed shape turns all the way round (360). If the turtle turns 60 for the triangle, ask the class to watch which way they end up facing.
One person types (driver), the other reads the task and checks each run (navigator). Swap at every new shape.
Pair programming keeps both students thinking and talking, and it helps students who are less confident.
Working out the turn angle for a shape. Ask how far the turtle turns in total and how many turns there are, instead of giving the number.
| What you will see | A question to ask | The fix |
|---|---|---|
| The triangle has a gap, or the shape looks like a star. | How many times does the loop repeat, and how far does the turtle turn each time? | A shape with 3 sides repeats 3 times and turns 120 degrees. All the turns add up to 360. |
| Only the first line repeats, or the program stops with an indentation error. | Which lines are pushed in under the for line? | The lines that repeat must be indented (four spaces) under the for line. |
| A student types forward(100) and right(90) many times and sees no reason to change. | How long would that be for a 50-sided shape? | Ask them to draw a 50-sided shape both ways. The loop stays 3 lines; the copied version needs 100. |
One possible solution for each task. Other correct programs are fine.
from turtle import *
for i in range(3):
forward(100)
right(120)
from turtle import *
for i in range(5):
left(90)
forward(20)
right(90)
forward(20)
Stretch: Draw a shape with 50 sides and turn 360 / 50 degrees. What does it start to look like, and why?
Support: Give the loop version and ask the student to change only one number at a time, running after each change.
A turtle draws a shape with 5 equal sides using a loop. How many times does the loop repeat, and how far does the turtle turn each time?
5 times, turning 72 degrees each time (360 divided by 5).
Loops come back in every lesson, and in tessellations, logo design and generative art. Next lesson stores numbers in variables, so the turn can be worked out instead of guessed. Then A street of houses reads a whole program that uses both. Class ideas: design a floor tile and repeat it; recreate a simple logo from code.