Question: Exercise 4 . 3 ( fractions . py ) . Any fraction can be written as the division of two integers. You could express this
Exercise fractionspy
Any fraction can be written as the division of two integers. You could express this in Python as
a tuple numerator denominator
For example, the fractions
and
can be represented using the tuples
and
Write the following functions:
reducefraction This function takes a fraction, reduces it and returns the result. For example,
reduce should return To reduce a fraction ab divide a and b by their
GCD The result is adbd The math module comes with the math.gcd function.
addfraction fraction Given two fractions as tuples, add them.
multiplyfraction fraction Given two fractions as tuples, multiply them.
dividefraction fraction Given two fractions as tuples, divide them.
These functions should not use input or print
Write a small commandline interface such that the user running your script sees something
like this:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
