Implement the remaining simple arithmetic operators sub mul


Assignment

Use the fraction.py file and complete the following:

1. Modify the Constructor for the Fraction class so that GCD is used to reduce fractions immediately. This means that the _add_ function no longer needs to reduce.

2. Implement the remaining simple arithmetic operators (_sub__, __mul __ and truediv ___).

3. Implement the remaining relational operators (__gt__,ge__, __lt__, __le__, and __ne__).

4. 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.

Attachment:- fraction.rar

Solution Preview :

Prepared by a verified Expert
Python Programming: Implement the remaining simple arithmetic operators sub mul
Reference No:- TGS02469683

Now Priced at $60 (50% Discount)

Recommended (91%)

Rated (4.3/5)