Program in python 3.x. Please add comments in order to increase understanding of
ID: 3872198 • Letter: P
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 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 gcdExplanation / Answer
This is the simplest code by importing modules.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.