Using a Turtle
Imagine a Turtle …
 Crawling over a huge
sheet of paper
 With a pen tied to its
tail.




You can command it.
The basics

Tells Python to use the
Turtle module

Sets up a Turtle and makes
it a Turtle Shape

Moves forward 100 pixels
Turns right by 90 degrees

Closes the graphic window
when you quit
Challenges


Draw a square:
 By repeating the same commands four times


 Using ‘For I in range(4):’ 



Draw a hexagon
Allow the user to say how many sides
the polygon should have
 Remember, use

‘myVariable = int(raw_input)’ to get a
number from the user


Get the turtle to draw your initials

Turtle graphics

  • 2.
    Using a Turtle Imaginea Turtle …  Crawling over a huge sheet of paper  With a pen tied to its tail.   You can command it.
  • 3.
    The basics Tells Pythonto use the Turtle module Sets up a Turtle and makes it a Turtle Shape Moves forward 100 pixels Turns right by 90 degrees Closes the graphic window when you quit
  • 4.
    Challenges  Draw a square: By repeating the same commands four times   Using ‘For I in range(4):’    Draw a hexagon Allow the user to say how many sides the polygon should have  Remember, use ‘myVariable = int(raw_input)’ to get a number from the user  Get the turtle to draw your initials