• Homework
  • Thirds
  • Upper Thirds
  • Fourth
  • Divisions
    • ICT
    • Computer Science
  • Fifth
  • Lower Sixth
  • Upper Sixth
    • Upper Sixth Theory
  • Blog
  • Careers
  • Unity
  • Networking

Turtle programming with Python

Click here for Advanced turtle programming

Picture
Imagine a Turtle …
   .. crawling over a huge sheet of paper
   With a pen tied to its tail.

You can command it.


Watch the classroom presentation

Turtle graphics from grahamwell

Try out the basic program

import turtle

turtle.shape("turtle")

turtle.forward(100)
turtle.right(90)

turtle.exitonclick()



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")
turtle.begin_fill()
turtle.end_fill()
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()

Click here for more turtle commands
Powered by Create your own unique website with customizable templates.