Use the fraction.py Modify the Constructor for the Fraction
You Are Eligible For 15% Discount This Month!
Use the fraction.py Modify the Constructor for the Fraction class so that GCD is sued to reduce fractions immediately. This means that the __add__ function no longer needs to reduce.Implement the remaining simple arithmetic operators (__sub__, __mul__, and __truediv__).Implement the remaining relational operators (__gt__, __ge__, __lt__, __le__, and __ne__).Modify the constructor for the Fraction class so that it checks to make sure that the numerator and denominator are both integers. If either is not an integer the constructor should raise an exception.
Leave a Reply
Want to join the discussion?Feel free to contribute!