Question: PYTHON 2.7 Consider the following Rational class (next page) that stores the numerator and the denominator as exact values. Rational objects can be created and

PYTHON 2.7

Consider the following Rational class (next page) that stores the numerator and the denominator as exact values. Rational objects can be created and used as:

>>> myFraction = Rational(3,4)

>>> anotherFraction = Rational(11, 8)

>>> fraction3 = myFraction + anotherFraction

  1. Modify the Rational class to include a method that overloads the * operator to perform multiplication, called __mul__.
  2. Test your code by calling __mul__ to assign productFraction the value of myFraction and anotherFraction?

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!