IT 117: Intermediate Scripting
Answers to Class 21 Ungraded Quiz


  1. What do you call the special class of methods that do things like provide a string representation of an object and convert one data type into another?
    magic methods
  2. What is the name of the method that will return a string representation of an object?
    __str__
  3. What is the name of the method that allows you to add two objects together?
    __add__
  4. What is the name of the method that allows you to subtract one object from another?
    __sub__
  5. What is the name of the method that allows you to multiply two objects together?
    __mul__
  6. What is the name of the method that allows you to divide one object by another and get a result of type float?
    __div__
  7. What is the name of the boolean method that allows you to test whether one object is equal to another?
    __eq__
  8. What is the name of the boolean method that allows you to test whether one object is not equal to another?
    __ne__
  9. What is the name of the boolean method that allows you to test whether one object is greater than another?
    __gt__
  10. What is the name of the boolean method that allows you to test whether one object is less than another?
    __lt__