Hello all,
I am struggling to write a fraction solver program in Python. This program needs to complete the following simple tasks: 1.) Given two fractions as tuples, multiply them. 2.) Given two fractions as tuples, divide them. and 3.) Give a list of fractions (as tuples) return the smallest value.
I am struggling to understand how tuple's, and how to perform the multiplication and division functions given the user input.
For example, here is what I currently have (very little):
#Fractions.py
import math
import functools
import string
def main():
while True:
fraction = input("Enter a fraction: ")
def frac_multiply(x,y):
numerator1, denominator1 = x
numerator2, denominator2 = y
return numerator, denominator
if __name__ == '__main__':
main()
Basically, the program should look like this when it runs:
Multiplication and Division:
Enter a fraction: 5/3
Enter a fraction: 10/3
Multiplication equals: 50/9
Division equals (the 1st by the 2nd)" 5/10
Smallest fraction:
Enter a fraction: 1/3
Enter a fraction: 10/3
Enter a fraction: 6/4
Smallest fraction: 1/3
I am stumped on how to perform any of the calculations when the user inputs n/d (numerator slash denominator)
Any help would be most appreciated.