Learning goals
- Lift and lower the turtle’s pen to control when it draws.
- Change the line color and width.
- Explain how pen settings affect the lines the turtle draws.
The turtle’s pen is down by default, so it draws as it moves. Use penup() to lift the pen. Use pendown() to lower it again.
import turtle as otto
otto.penup()
otto.backward(75)
otto.pendown()
otto.forward(50)
otto.penup()
otto.forward(50)
otto.pendown()
otto.forward(50)

The turtle starts in the middle and faces right. With its pen up, backward(75) moves it 75 units left without drawing. The turtle draws two lines of 50 units, with a 50 unit gap between them.
Use color() to set the line color. Put a color name, such as "blue", inside quotes. Use pensize() to set the line width.
import turtle as otto
otto.penup()
otto.backward(40)
otto.pendown()
otto.color("blue")
otto.pensize(4)
otto.forward(80)

The line is blue and 4 units wide. You can choose other color names and line widths.
Try it yourself: Click the Run button. The drawing appears below the code.
Then choose another color and a thicker line. Click Run again. You can find more color names at the bottom of this page.
import turtle as otto
otto.penup()
otto.backward(40)
otto.pendown()
otto.color("blue")
otto.pensize(4)
otto.forward(80)
You can change the color whenever you like. Each line keeps the color set when Turtle drew it.
import turtle as otto
otto.penup()
otto.backward(105)
otto.pendown()
otto.color("red")
otto.forward(100)
otto.penup()
otto.forward(50)
otto.pendown()
otto.color("blue")
otto.forward(100)

The turtle draws a red line, moves without drawing, then draws a blue line.
| Command | What it does |
|---|---|
otto.penup() |
Lifts the pen so movement does not draw. |
otto.pendown() |
Lowers the pen so movement draws again. |
otto.color(color) |
Sets the line color, for example "red". |
otto.pensize(width) |
Sets the line width. |
The labels show color names that otto.color() can use. Put the name in quotation marks, like otto.color("red").
