Turtle programming with Python |
Click here for Advanced turtle programming |
Imagine a Turtle …
.. crawling over a huge sheet of paper
With a pen tied to its tail.
You can command it.
.. crawling over a huge sheet of paper
With a pen tied to its tail.
You can command it.
Watch the classroom presentation |
Try out the basic program |
import turtle |
Use these additional turtle features and commands:
turtle.forward(distance) |
Moves the turtle forward by the specified distance in the direction the turtle is headed
|
turtle.backward(distance) |
Moves the turtle backward by distance, opposite to the direction that the turtle is headed.
|
turtle.speed(speed) |
Speeds up or slows down the turtles movement. Values of speed are between 1 (slow) and 10 (fast). If you want the turtle to move instantly, set speed to zero.
|
turtle.right(angle) |
Turn the turtle angle degrees to the right. This doesn't draw anything, but sets a new orientation for subsequent forward drawing.
|
turtle.left(angle) |
Turn the turtle angle degrees to the left. Again, this doesn't draw anything but sets a new orientation for subsequent drawing.
|
turtle.pencolor("color") |
Changes the color (note the American spelling) of the pen. Try different values in quotes, such as "red", "blue", "brown", "green"
|
turtle.fillcolor("color") |
Fills in the shapes that a turtle draws with the fill colour. Set the fill colour first using colour names in quotes eg: "red", then use begin_fill(), draw the shape, finally use end_fill()
|