Question: Python. Please include comments where needed, explaining the code and screenshot of output. thank you! Suppose we want to do arithmetic with rational numbers. We

Python. Please include comments where needed, explaining the code and screenshot of output. thank you!

Suppose we want to do arithmetic with rational numbers. We want to be able to add, subtract,

multiply, and divide them and to test whether two rational numbers are equal.

We can add, subtract, multiply, divide, and test equality by using the following relations:

n1/d1 + n2/d2 = (n1*d2 + n2*d1)/(d1*d2)

n1/d1-n2/d2 = (n1*d2-n2*d1)/(d1*d2)

n1/d1 * n2/d2 = (n1*n2)/(d1*d2)

(n1/d1) / (n2/d2) = (n1*d2)/(d1*n2)

n1/d1 == n2/d2 if and only if n1*d2 == n2*d1

Define

a rational number class

with support for arithmetic operations (subtract, multiply, divide, and test equalitymethods) as follows:

class

RationalNumber:

"""

Rational Numbers with support for

arithmetic

operations.

"""

### your code

here

####

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!