The following is the question, and I don't know how to write the __setattr__ method. Complete the class Fraction, which stores and manipulates fractions stored as pairs of numbers: a numerator and a denominator. As specified below, write the required methods, including those needed for overloading operators. Write the __setattr__ method to prohibit a change to the num and denom self/instance variables once they are initialized in __init__. Hint: if a name is not already in __dict__ allow it to be added; but if a name is already in __dict__ raise a NameError exception.
Get Free Quote!
357 Experts Online