Question: Program in python 3.x. Please add comments in order to increase understanding of the solution. (If possible try to make the code as simple as
Program in python 3.x. Please add comments in order to increase understanding of the solution. (If possible try to make the code as simple as possible). Thanks
Fractions: You can express a fraction as a tuple: (numerator, denominator) (a) Write a function that adds two fractions that are passed as tuples (b) Write a function that multiplies two fractions that are passed as tuples. HINT: Use the following function gcd(x,y) to help you calculate the Greatest Common Divisor, which you will need to reduce fractions to the simplest form.] def gcd (x, y): To calculate the greatest common divisor of and y" x1 = abs (min(x, y)) y1 = abs (max (x, y)) gcdx1 if y1 % x1: gcd- gcd(x1, y1 % x1) return gcd
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
