π― Today you will learn toβ¦
- Use FD, RT, LT, BK, PU and PD to move the turtle and draw shapes
- Use REPEAT to write shorter, cleaner code
- Reposition the turtle using PU / PD to add details like a door and windows
- Fill shapes with colour using FILLED
- Write named procedures (TO β¦ END) and combine them into a full house program
Command Reference
Keep this open as you work today
| Action | Command | Example |
|---|---|---|
| Move forward | FD x | FD 100 |
| Move backward | BK x | BK 50 |
| Turn right | RT x | RT 90 |
| Turn left | LT x | LT 45 |
| Lift pen (stop drawing) | PU | PU |
| Lower pen (start drawing) | PD | PD |
| Repeat commands x times | REPEAT x [...] | REPEAT 4 [FD 100 RT 90] |
| Set pen colour (number) | SETPENCOLOR x | SETPENCOLOR 4 (red) |
| Set fill colour and draw | FILLED "colour [...] | FILLED "blue [REPEAT 4 [FD 100 RT 90]] |
| Create a procedure | TO name ... END | TO walls ... END |
| Shape | Sides | Turn |
|---|---|---|
| Triangle | 3 | 120Β° |
| Square | 4 | 90Β° |
| Pentagon | 5 | 72Β° |
| Hexagon | 6 | 60Β° |
| Octagon | 8 | 45Β° |
The Walls π§±
Draw the main body of the house β a square
The turtle will go forward 4 times, turning right each time to make the corners.
Your target: a square with side length 100 steps
π§ Plan it first: Without looking at the hint, write out the commands in plain English below.
My Plan (English):
π» Now write the Turtle code: Fill in the blanks.
repeat [ fd rt ]
Think:
repeat 4 [...] β what goes inside?
π Show Worked Answer (try first!)
repeat 4 [ fd 100 rt 90 ]
The exterior angle of a square = 360 Γ· 4 = 90Β°. The turtle repeats: go forward 100, turn right 90Β° β four times.
The Roof πΊ
Add a triangle on top β and learn to reposition the turtle
Target: triangle sitting directly on top of the square
Triangle β 360 Γ· 3 = 120Β° turn at each corner.
π€ Think about it: After your walls code runs, where is the turtle and which way is it facing?
My Thinking:
π» Complete the code β the walls are done, now add the roof:
repeat 4 [ fd 100 rt 90 ]
; Move to top-left corner without drawing
pu
fd ; move up one wall length
pd
; Draw the roof triangle
repeat [ fd rt ]
fd 100). Then for the triangle: repeat 3 [fd 100 rt 120]. You might need to adjust your starting direction β experiment!
π Show Worked Answer
pu fd 100 pd
repeat 3 [ fd 100 rt 120 ]
PU lets you reposition the turtle without leaving a line. PD starts drawing again. The triangle exterior angle = 360 Γ· 3 = 120Β°.
βοΈ Reflection
Door & Windows πͺπͺ
Use PU/PD to add details β practice repositioning the turtle
Target: door in the centre, windows on each side
Door sizes: width = 25 steps, height = 40 steps (a rectangle)
Window sizes: width = height = 25 steps (a square)
π» Write the full code for door and windows. Add it to your house code:
pu ; lift pen, move to door position
; (adjust FD/RT values to position correctly)
fd rt fd
pd ; start drawing
; draw door rectangle:
fd rt 90 fd rt 90 fd rt 90 fd
; === WINDOW 1 ===
pu ; move to window position
pd
repeat [ fd rt ]
fd 40 rt 90 fd 25 rt 90 fd 40 rt 90 fd 25For a window (square):
repeat 4 [fd 25 rt 90]Use PU + FD + RT to reposition between each shape. Experiment with the numbers to get the positioning right!
Colour Fills π¨
Use FILLED and SETPENCOLOR to bring your house to life
| Colour name | Number code |
|---|---|
| "red | 4 |
| "blue | 1 |
| "green | 2 |
| "yellow | 6 |
| "orange | 14 |
| "brown | 8 |
| "white | 7 |
| "gray | 15 |
Example β a red filled square:
filled "brown [ fd 40 rt 90 fd 25 rt 90 fd 40 rt 90 fd 25 ]Put your PU/PD positioning before the filled command, not inside it.
Command Match π―
Match each command to what it does β click one from each column
print posprint headinglabel "turtlesetlabelfontrepeat 8 [fd 70 lt 45]repeat 4 [fd 100 lt 90]Refactor Challenge βοΈ
Spot the pattern β squash the bloat down to one repeat
repeat command?
Extension: Garden Scene π³βοΈ
If you finish everything β design your own scene
repeat to keep your code clean!
Rectangle trunk +
repeat 360 [fd 1 rt 1]
repeat 36 [fd 5 rt 10] for a circle
Try repeating a petal shape
Rectangles leading to the door
Overlapping circles with PU/PD
Two rectangles + two circles