Quiz 03 Practice


Questions

Solutions for each problem can be found at the bottom of this page.

Conceptual Questions

  1. A class definition provides a pattern for creating objects, but doesn’t make any objects itself. (T/F)
  2. By convention, Python class names start with a lowercase letter. (T/F)
  3. When you define a method in a class, all objects of that class have that method associated with it. (T/F)
  4. The first parameter of a method is a copy of the object the method is called on. (T/F)
  5. A class definition must come before an object of that class is instantiated. (T/F)
  6. You must have an instance of a class (an object) to call the class’s constructor. (T/F)
  7. Constructors must have the self parameter in their signature. (T/F)
  8. Constructors must take at least one parameter other than the self parameter. (T/F)
  9. Objects are passed into functions by reference. (T/F)
  10. The type of an object is the same as the name of the class it is an instance of. (T/F)
  11. A method is not pure if it creates a new object. (T/F)
  12. Required (positional) arguments always come before optional arguments. (T/F)
  13. Union types allow for arguments to be one of multiple types. (T/F)

Memory Diagrams

  1. Produce a memory diagram for the following code snippet, being sure to include its stack and output.

  2. Produce a memory diagram for the following code snippet, being sure to include its stack and output.

  3. Produce a memory diagram for the following code snippet, being sure to include its stack and output.

Solutions

Conceptual Questions

  1. True
  2. False
  3. True
  4. False
  5. True
  6. False
  7. True
  8. False
  9. True
  10. True
  11. False
  12. True
  13. True

Memory Diagrams

Contributor(s): Megan Zhang, David Karash