Questions
Solutions for each problem can be found at the bottom of this page.
Conceptual Questions
- A class definition provides a pattern for creating objects, but doesn’t make any objects itself. (T/F)
- By convention, Python class names start with a lowercase letter. (T/F)
- When you define a method in a class, all objects of that class have that method associated with it. (T/F)
- The first parameter of a method is a copy of the object the method is called on. (T/F)
- A class definition must come before an object of that class is instantiated. (T/F)
- You must have an instance of a class (an object) to call the class’s constructor. (T/F)
- Constructors must have the
self
parameter in their signature. (T/F) - Constructors must take at least one parameter other than the self parameter. (T/F)
- Objects are passed into functions by reference. (T/F)
- The type of an object is the same as the name of the class it is an instance of. (T/F)
- A method is not pure if it creates a new object. (T/F)
- Required (positional) arguments always come before optional arguments. (T/F)
- Union types allow for arguments to be one of multiple types. (T/F)
Memory Diagrams
Produce a memory diagram for the following code snippet, being sure to include its stack and output.
Produce a memory diagram for the following code snippet, being sure to include its stack and output.
Produce a memory diagram for the following code snippet, being sure to include its stack and output.
Solutions
Conceptual Questions
- True
- False
- True
- False
- True
- False
- True
- False
- True
- True
- False
- True
- True