IT 117: Intermediate Scripting
Answers to Class 23 Ungraded Quiz

  1. If I wanted to define the class Cat which is a based upon the class Pet, what would I write for a class header?
    class Cat(Pet)
  2. Let's say that the constructor for the Pet class takes only 1 argument, the name of the pet. Write the Python statement you would use to call the Pet constructor within the Cat constructor code.
    Pet.__init__(self, name)
  3. If I wanted to call the __str__ method of the Pet class inside a method in the Cat class, what expression would I write?
  4. Let's say that both the Pet class and the Cat class have a method named get_name. If we call get_name on a Cat object, which class's version of this function will be used?
  5. If I had a variable named var that pointed to an object and wanted to know whether this was an instance of the class Cat, what boolean expression would I write?
    isinstance(var, Cat)