
Everything the turtle has drawn so far has been joined up, because the pen has been down the whole time. A drawing with two separate things in it needs a way to move without leaving a trail.
Two instructions, and neither takes a number:
| Type | Short for | What it does |
|---|---|---|
pu |
pen up | The turtle still moves, but draws nothing |
pd |
pen down | Back to drawing |
The turtle keeps moving and turning exactly as before. The only thing that changes is whether a line appears behind it.
That is worth saying plainly, because it is easy to think of pu as "stop" -
it is not. pu followed by fd 40 puts the turtle forty steps further on, and
the next thing you draw will start from there.
Put pu and pd inside a repeat and you get a dashed line: draw a bit, skip
a bit, over and over.
repeat 5 [pd fd 15 pu fd 10]
Each time round: pen down, draw fifteen steps, pen up, skip ten. The pd at the
start of the list matters - without it, the second time round would begin with
the pen still up from the end of the first.
ss
cs
rt 90
repeat 5 [pd fd 15 pu fd 10]
Starting from
A fresh boot, at the ? prompt. The rt 90 turns the turtle to face right
before it sets off, so the dashes run across the screen rather than up it -
there is more room that way.
What you should see
Five dashes running to the right from the middle of the screen, each one about fifteen steps long with a ten-step gap after it, and the turtle at the far right end pointing right.

pd and the pu round, so the list reads pu fd 15 pd fd 10. You
still get dashes. What is different about them, and where does the line now
start?pu fd 10 to pu fd 30, leaving everything else. Count the dashes
before you run it, then count them afterwards. Why are there fewer?pu out altogether, leaving repeat 5 [pd fd 15 fd 10]. What do you
get, and what does that tell you about what fd 15 fd 10 does on its own?| Symptom | Cause |
|---|---|
| Nothing is drawn at all | The pen is up from something you did earlier. pd puts it back down; cs also resets it. |
| The first dash is missing but the rest are there | The pen was up when the repeat started. That is what the pd at the front of the list is for. |
| The dashes stop before the edge of the screen | You have run out of room. Five dashes of 15 with 10-step gaps is 125 steps, and there are about 128 to the right of the middle. |
| You get one long line instead of dashes | The pu is missing, or there is no space between it and the instruction after it. |
pu lifts the pen and pd puts it down. The turtle moves the same either way -
only the line changes. Putting both inside a repeat is how you draw something
with gaps in it.
S7, colour - the pen does not have to be white.