Checkpoint 9.11.1.
- none
- A turtle named Alex is created on line 16
- 1
- Yes, one turtle is created, and then is passed around and modified
- 2
- A turtle is a mutable object, and it is passed around and modified in this program
- It depends on how often the end user clicks
- A turtle is a mutable object, and it is passed around and modified in this program
How many turtles are created in this script?
import turtle
import random
def write_msg(tom, msg, x, y):
tom.penup()
tom.goto(x,y)
tom.pendown()
tom.write(msg)
return tom
def here(x, y):
global alex
alex = write_msg(alex, "You clicked here!", x, y)
wn = turtle.Screen() # Set up the window and its attributes
alex = turtle.Turtle() # create alex
alex = write_msg(alex, "Hello!", 0, 0)
wn.onclick(here)
wn.listen()