5.5. Single and Multiple Turtles

You may remember this example as well.

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

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, <img src=”../_static/TwoTurtles1N.png” width=”150” align=”left” hspace=”10” vspace=”5” />. The program should do all set-up, have “jamal” draw the L, and then have “tina” draw the line. <br /><br /><p>Drag the blocks of statements from the left column to the right column and put them in the right order. Then click on <i>Check Me</i> 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.</p>

        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)
        

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 <img src=”../_static/TwoTurtlesLN.png” width=”150” align=”left” hspace=”10” vspace=”5” />. 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. <br /><br /><p>Drag the blocks of statements from the left column to the right column and put them in the right order. Then click on <i>Check Me</i> 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.</p>

        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
        

Note

Discuss topics in this section with classmates.

Show Comments
You have attempted of activities on this page