5.11. Chapter Assessment - Turtle and Object Mechanics

Check your understanding

    turtle-11-1: What are correct ways to tell a turtle named Tex to move forward 20 pixels? Select as many as apply.
  • Tex.forward(20)
  • This is a correct way to move a turtle forward.
  • forward() + 20
  • This does not use the turtle method necessary to move a turtle forward. Additionally, how would the program know what turtle should be moving?
  • forward(20)
  • This does not use the turtle method necessary to move a turtle forward. Additionally, how would the program know what turtle should be moving?
  • forward(20).Tex
  • This is not the correct structure to execute the task.
  • Tex.forward(10 + 10)
  • You are allowed to write expressions inside of methods, so this is correctly written.
    turtle-11-2: Which is the correct way to make a new instance of the Turtle class?
  • turtle(Turtle)
  • When making a new instace of the turtle class, you need to use dot notation.
  • turtle.Turtle()
  • Yes, this is the correct way.
  • Turtle.turtle()
  • turtle represents the class and should be first.
  • Turtle(turtle)
  • When making a new instace of the turtle class, you need to use dot notation.
    turtle-11-3: What does each instance of the Turtle class represent?
  • The turtle class.
  • Though each instance does use the turtle class, this is not the best answer.
  • The same turtle that is used in each drawing your programs make.
  • Each instance that is made using the turtle class is unique. Remember how you can have multiple 'turtles' in a single drawing? Each of those are different turtles but they are all instances of the turtle class.
  • A unique 'turtle' that you can use to draw.
  • Yes, an instance of the turtle class represents a unique turtle. The turtle class is like a stencil or mold that can be used to make as many turtles as you would like.
    turtle-11-4: True or False, attributes/instance variables are just like other variables in Python.
  • True
  • Just like the variables you've learned about so far, you can assign values to an attribute and look up the values that are assigned to the attribute.
  • False
  • The only difference is the structure that is used to refer to it.
    turtle-11-5: Select all of the following things that methods can do:
  • Change the value of an attribute.
  • Methods can change the value that is associated with an attribute.
  • Return values.
  • Methods can return values.
  • Create new attributes and set their value.
  • Methods can create new attributes and then set that attribute's value.
  • Delete instances of a class.
  • Methods cannot delete instances of a class.
  • None of the above.
  • Methods can do at least one of the above. Take another look.
    turtle-11-6: For an instance of a class that is assigned to the variable student, what is the propper way to refer to the title attribute/instance variable?
  • student.title()
  • This is not the structure used to refer to an attribute.
  • title.student()
  • This is not the structure or order used to refer to an attribute.
  • title.student
  • This is not the order used to refer to an attribute.
  • student(title)
  • This would be the syntax for a function named student being called on a variable named title.
  • student.title
  • Yes, this is the correct structure to use.

turtle-11-7: What is the name of the attribute in the following code?

import turtle

jane = turtle.Turtle()
jane.forward(20)
print(jane.x)

The attribute is

turtle-11-8: What is the name of the instances in the following code? Please put one instance per blank space and enter them in the order that the computer would read them.

import turtle
wn = turtle.Screen()

jazz = turtle.Turtle()
jazz.forward(50)
jazz.right(90)
pop = turtle.Turtle()
pop.left(180)
pop.forward(76)

5.12. Chapter Assessment - Drawing with Turtle

Check your understanding

Write a program that uses the turtle module to draw something. It doesn’t have to be complicated, but draw something different than we have done in the past. (Hint: if you are drawing something complicated, it could get tedious to watch it draw over and over. Try setting .speed(10) for the turtle to draw fast, or .speed(0) for it to draw super fast with no animation.)
Next Section - 5.13. 🤔 Drawing a Circle with the Turtle