Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please us python file and put the question number in front of the answer so i know which answer to which 1.Implement the simple methods

please us python file and put the question number in front of the answer so i know which answer to which

1.Implement the simple methods getNum and getDen that will return the numerator and denominator of a fraction.

2.In many ways it would be better if all fractions were maintained in lowest terms right from the start. Modify the constructor for the Fraction class so that GCD is used to reduce fractions immediately. Notice that this means the __add__ function no longer needs to reduce. Make the necessary modifications.

3.Implement the remaining simple arithmetic operators (__sub__, __mul__, and __truediv__).

4.Implement the remaining relational operators (__gt__, __ge__, __lt__, __le__, and __ne__)

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+3. In what season of the year did you move to Cedar Rapids?

Answered: 1 week ago

Question

=+5 Does this case provide an example of the future for IHRM?

Answered: 1 week ago

Question

=+4 How did it affect HR?

Answered: 1 week ago