Provide a Python implementation of Fraction ADT

Python provides a numeric class for working with floating-point values. But not all real numbers can be represented precisely on a computer since they are stored as binary values. In applications where the precision of real numbers is important, we can use rational numbers or fractions to store exact values. A fraction, such as , consists of two parts, both of which are integers. The top value, which can be any integer value, is known as the numerator. The bottom value, which must be greater than zero, is known as the denominator.

(a) Define a Fraction ADT to represent and store rational numbers. The ADT should include all of the common mathematical and logical operations. In addition, your ADT should provide for the conversion between floatingpoint values and fractions and the ability to produce a string version of the fraction.

(b) Provide a Python implementation of your Fraction ADT.

Leave a Reply

Your email address will not be published. Required fields are marked *