Code to set-up the Turtle Programming Environment
import turtle
t=turtle.Turtle() #name of the turtle (t) / you can add more turtles here
wn=turtle.Screen() #Creates the turtle window
t.fd(30) #All turtle commands go after row above and before row below
wn.exitonclick() #Do NOT delete must go at the end
Turtle Movement and Turning Commands
t.fd(50) #Turtle moves forwards 50
t.bk(50) #Turtle moves back 50
t.rt(90) #Turtle turns right 90 degrees
t.lt(90) #Turtle turns left 90 degrees
t.setpos(-100,-100) #uses cartesian coordinates to move turtle (x,y)
Drawing Circles and Regular Polygons
t.circle(100) #Turtle draws a circle with radius of 100
t.circle(40,180) #Turtle draws a circle radius of 40 but only draws 180 degrees (half circle)
t.circle(40,360,6) #Radius 40, 360 degrees, 6 sides (hexagon)
t.circle(70,360,3) #Radius 70, 360 degrees, 3 sides (triangle)
t.dot(40) #Filled in circle with radius of 40
Turtle Start and Stop Drawing Commands
t.pu() #Turtle stops drawing (pen up) but can still move
t.pd() #Turtle starts drawing (pen down)
Turtle Looks, Speed and Position Commands
t.clear() #Clears the screen of all lines drawn
t.width(1) #Sets line width
t.shape("arrow") #“turtle”, “circle”, “square”, “triangle”, “classic”
t.speed(10) #0=instant 1=slowest 10=fast 6=normal
t.home() #turtle returns to start position
t.stamp() #Stamps a copy of the turtle image on the screen
t.undo(6) #undo last 6 turtle commands
Turtle Pen and Shape Colour Commands
t.pencolor("green") #set pen colour to green (can use rgb values)
t.fillcolor("Blue") #shapes filled will be blue inside (begin_fill & end_fill must be used)
t.begin_fill() #Starts filling colour (is needed with end_fill)
t.end_fill() #Stops filling colour (is needed with begin_fill)
t.fillcolor("yellow") #example code to make circle yellow
t.begin_fill()
t.circle(60)
t.end_fill()
Showing and Hiding the Turtle
t.ht() #Hide turtle
t.st() #Show turtle
Changing How the Turtle Window Looks
wn.title("My Turtle Program") #Sets the Title of the window
wn.bgcolor("blue") #Background colour of the window
