Students read a longer program that combines the counter, a list, an update and a decision, find the lines that do each job, and change one part without breaking the rest.
Load these into Waypoints Prepare: choose Load URL and paste the copied address, 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 12 min · Modify 13 min
Run the garden, then do the Modify tasks yourself. The program is a loop with a long body: that length is what the next lesson fixes.
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.
Here is the finished program running. By the end of the lesson you will write one like it.
Run the finished example on the projector before anything else.
Pairs colour the garden lines on paper: stem, head, spacing, decision. Compare with the next pair.
Make the idea physical before it goes back to the screen.
Knowing which lines to change. Ask what job the new feature is, then which lines do that job.
| What you will see | A question to ask | The fix |
|---|---|---|
| The extra flowers run off the screen. | Where does the first flower start, and how far apart are the flowers? | Move the start further left with goto, for example goto(-200, -80). |
| Changing one thing breaks another. | Which other lines use the name you changed? | Find every line that uses it before you change it. A name is used wherever it appears. |
One possible solution for each task. Other correct programs are fine.
from turtle import *
speed(0)
colours = ["red", "orange", "pink", "purple", "gold", "teal"]
stem = 50
head = 10
penup()
goto(-200, -80)
pendown()
for i in range(len(colours)):
if i % 2 == 0:
pencolor("green")
else:
pencolor("darkgreen")
pensize(3)
left(90)
forward(stem + i * 10)
fillcolor(colours[i])
begin_fill()
circle(head)
end_fill()
head = head + 4
penup()
backward(stem + i * 10)
right(90)
forward(70)
pendown()
from turtle import *
speed(0)
colours = ["red", "orange", "pink", "purple"]
stem = 50
head = 10
penup()
goto(-150, -80)
pendown()
for i in range(len(colours)):
if i % 2 == 0:
pencolor("green")
else:
pencolor("darkgreen")
pensize(3)
left(90)
forward(stem)
fillcolor(colours[i])
begin_fill()
circle(head)
end_fill()
head = head + 4
penup()
backward(stem)
right(90)
forward(70)
pendown()
Stretch: Make every other flower head a different shape by adding a decision to the flower-head lines.
Support: Colour or underline the lines for each job on paper before changing anything.
In the garden, which part would you change to make every flower head the same size?
The update head = head + 4. Remove it, or set head once and never add to it.
Next lesson names a group of lines (a function). The garden's long loop body is the first thing to name.