Single and Multiple Turtles¶
You may remember this example as well.
What shape will the program below draw when you click on the Run button?
This works because zari
is a turtle, and each statement gets executed, one right after the other. If we introduce another turtle and another name, it doesn’t work the same
Every turtle object has its own attributes like its current position and color. So, when we created chad his position was different from zari’s. Turtles start off in the center of the drawing space when they are first created.
Mixed up programs
csp-5-4-2: csp-5-4-1: The following program has one turtle, "jamal", draw a capital L in blue and then another, "tina", draw a line to the west in orange as shown to the left, . The program should do all set-up, have "jamal" draw the L, and then have "tina" draw the line.
Drag the blocks of statements from the left column to the right column and put them in the right order. Then click on Check Me to see if you are right. You will be told if any of the lines are in the wrong order or are the wrong blocks.
from turtle import *
wn = Screen()
---
jamal = Turtle()
jamal.pensize(10)
jamal.color("blue")
---
jamal.right(90)
jamal.forward(150)
---
jamal.left(90)
jamal.forward(150) #paired
---
jamal.left(90)
jamal.forward(75)
---
jamal.right(90)
jamal.forward(75) #paired
---
tina = Turtle()
tina.pensize(10)
tina.color("orange")
---
tina = Turtle()
tina.pensize(10)
tina.color(orange) #paired
---
tina.left(180)
tina.forward(75)
csp-5-4-4: csp-5-4-3: The following program has one turtle, "jamal", draw a line to the north in blue and then another, "tina", draw a line to the east in orange as shown to the left . The program should import the turtle module, get the window to draw on, create the turtle "jamal", have it draw a line to the north, then create the turtle "tina", and have it draw a line to the east.
Drag the blocks of statements from the left column to the right column and put them in the right order. Then click on Check Me to see if you are right. You will be told if any of the lines are in the wrong order or are the wrong blocks.
from turtle import *
---
from turtle #paired
---
wn = Screen()
---
jamal = Turtle()
---
jamal = turtle() #paired
---
jamal.color("blue")
jamal.pensize(10)
jamal.left(90)
jamal.forward(150)
---
tina = Turtle()
tina.pensize(10)
---
tina.color("orange")
tina.forward(150)
---
tina.color("orange")
tina.Forward(150) #paired