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

Advanced Turtle programming commands

Click here for Advanced challenges

Change the background colour of the Turtle's window



import turtle
window = turtle.Screen()
window.bgcolor("lightgreen")
window.title("Light Green World")


You can choose between the standard colours "white", "black", "red", "green", "blue", "cyan", "yellow", and "magenta"
Picture

Two turtles working independently - Alex and Tess


alex = turtle.Turtle()
alex.shape("turtle")

tess = turtle.Turtle()
tess.shape("square")

for i in range(numberofsides):
    tess.right(360/numberofsides)
    tess.forward(100)
    alex.right(180-(180/numberofsides))
    alex.forward(120)



You can create as many turtles as you want.
Picture

Multi-coloured output


mycolors = ["red","yellow","green","blue","purple","black"]
for i in mycolors:
    turtle.color(i)
    turtle.forward(100)
    turtle.right(60)
Picture

Using 'stamp()' to draw a picture at the position

turtle.shape("turtle")
turtle.penup()              # Don't draw a line
size = 20
for i in range(30):
   turtle.stamp()             # Leave an impression
   size = size + 3            # Increase the size
   turtle.forward(size)       # Move tess along
   turtle.right(24)           #  ...  and turn her
Picture

using turtle.goto() to move directly to a position

for i in range(12):
        turtle.penup()        # stops drawing                turtle.goto(0,0)

        turtle.right(360/12)
        turtle.pendown()      # starts drawing 
        turtle.forward(100)
Picture
Powered by Create your own unique website with customizable templates.