Students read a tile pattern that combines loops, names, a list and the remainder, change it, and make a tile of their own.
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 8 min · Investigate 8 min · Modify 8 min · Make 16 min
Run the tile, then make a checkerboard yourself. The tricky part is backward(size * 4) at the end of a row: it must match the number of columns.
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.
Each pair changes one thing, writes down what they expect, then runs it. Share the biggest surprise.
Make the idea physical before it goes back to the screen.
Walk round and look at three tiles. Guess each tile's rule from the picture before you read its code.
Planning the pattern before coding. Ask them to colour a small grid on paper and say the rule in words first.
| What you will see | A question to ask | The fix |
|---|---|---|
| The rows do not line up, or each row starts further right. | How far does the turtle move along a row, and how far does it come back? | Come back by size times the number of columns: backward(size * 5) for 5 columns. |
| An IndexError on the colours line. | Is the place always less than len(colours)? | Use the remainder with len(colours): (row + col) % len(colours). |
| The tile is one colour. | What does the decision depend on? Does it change as row and col change? | The condition must use row or col, or the remainder of them. |
One possible solution for each task. Other correct programs are fine.
from turtle import *
colours = ["gold", "navy", "teal", "tomato"]
size = 40
speed(0)
penup()
goto(-100, -80)
for row in range(4):
for col in range(5):
pick = (row + col) % len(colours)
fillcolor(colours[pick])
begin_fill()
for side in range(4):
forward(size)
right(90)
end_fill()
forward(size)
backward(size * 5)
left(90)
forward(size)
right(90)
from turtle import *
colours = ["pink", "purple", "teal"]
size = 30
speed(0)
penup()
goto(-90, -60)
for row in range(4):
for col in range(6):
if (row + col) % 2 == 0:
fillcolor(colours[col % len(colours)])
else:
fillcolor("white")
begin_fill()
for side in range(4):
forward(size)
right(90)
end_fill()
forward(size)
backward(size * 6)
left(90)
forward(size)
right(90)
Stretch: Make the tile grow: each square a little bigger than the one before, using an update.
Support: Give the working tile and ask the student to change only the list of colours, then only the size.
A grid has 5 rows and 6 columns. How many squares is that, and which line would you change to get 8 columns?
30 squares. Change the number in the inner loop, range(6), and the backward(size * 6) line to match.
Course B starts from a working program and builds up to a game: functions, modules and events. Class ideas: print the tiles and arrange them in a class wall.