This program draws a red line, moves without drawing, then draws a blue line.
import turtle as otto
otto.color("red")
otto.pensize(3)
otto.forward(60)
otto.left(90)
otto.forward(40)
otto.penup()
otto.goto(-40, 20)
otto.pendown()
otto.color("blue")
otto.pensize(5)
otto.right(90)
otto.backward(50)
| Code or command | What it does |
|---|---|
import turtle as otto |
Makes drawing commands available under the short name otto. |
forward(distance) |
Moves forward by distance in the direction the turtle faces. |
backward(distance) |
Moves backward by distance, opposite to the direction it faces. |
left(angle) |
Turns left by angle. |
right(angle) |
Turns right by angle. |
goto(x, y) |
Moves to position (x, y). |
penup() |
Lifts the pen so movement does not draw. |
pendown() |
Lowers the pen so movement draws again. |
color(color) |
Sets the line color, for example "red". |
pensize(width) |
Sets the line width. |