Question: Using Python 3 Implement a class of rational numbers (ratio of integers) with the following interfaces and behaviours >>> r = Rational (3,4) >>> repr(r)
Using Python 3 
Implement a class of rational numbers (ratio of integers) with the following interfaces and behaviours >>> r = Rational (3,4) >>> repr(r) 3/4' >>> -1/r -4/3 >>> float(-1/r) -1.3333333333333333 >>> int(r) 0 >>> int(Rational(10,3)) 3 >>> Rational(10,3) * Rational (101,8) - Rational(11,8) 977/24 >>> sorted([Rational(10,3), Rational(9,8), Rational (10,1), Rational(1,100)]) (1/100, 9/8, 10/3, 10] >>> Rational (100,10) 10 >>> Rational (12345,128191) + Rational (101,103) * 30/ 44 166235595/290480806 Please put your Python code in a Python script file and upload it
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
