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

computer science

Description

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.


Related Questions in computer science category


Disclaimer
The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.