import turtle wn = turtle.Screen() wn.bgcolor("lightblue") tom = turtle.Turtle() # create an instance of Turtle, assign it to tom # notice tom is facing right tom.forward(50) # tell tom to move forward by 50 units tom.left(90) # tell tom to turn by 90 degrees tom.forward(30) # tell tom to move forward by 30 units # tell tom to turn and move to draw a rectangle tom.left(90) tom.forward(50) tom.left(90) tom.forward(30) # Speed settings can be set # between 1 (slowest) to 10 (fastest). # But if we set the speed to 0, # it has a special meaning # — turn off animation and go as fast as possible. tom.speed(0) # modify the code to draw a square, a triangle, # a pentagon, a hexagon, an octagon tom.penup() tom.forward(100) tom.pendown() for i in range(4): tom.forward(50) tom.left(360/4) tom.penup() tom.right(90) tom.forward(100) tom.pendown() for i in range(3): tom.forward(50) tom.left(360/3) tom.penup() tom.right(90) tom.forward(100) tom.pendown() for i in range(5): tom.forward(50) tom.left(360/5) tom.penup() tom.left(90) tom.forward(100) tom.pendown() for i in range(6): tom.forward(50) tom.left(360/6) tom.penup() tom.right(90) tom.forward(100) tom.pendown() for i in range(8): tom.forward(50) tom.left(360/8) # tell tom to turn and move, then draw a circle tom.penup() tom.right(90) tom.forward(100) tom.pendown() tom.circle(60) # radius = 60 # tell tom to go to a specific position (x,y) coordinate # on the screen, then draw a solid orange circle tom.penup() tom.goto(0,200) tom.pendown() tom.circle(50) tom.begin_fill() tom.color("orange") tom.circle(50) tom.end_fill() tom.penup() tom.goto(100, 0) tom.color("red") tom.shape("turtle") step = 10 for i in range(30): tom.stamp() # Leave an impression on the canvas step = step + 2 # Increase the size on every iteration tom.forward(step) # Move tess along tom.left(25) # ... and turn tom wn.mainloop() # wait for user to close the window