Find the best solutions to your questions at Westonci.ca, the premier Q&A platform with a community of knowledgeable experts. Discover comprehensive answers to your questions from knowledgeable professionals on our user-friendly platform. Get quick and reliable solutions to your questions from a community of experienced experts on our platform.
Sagot :
Answer:
fraction = input("enter fraction x/y: ")
if len(fraction) == 3:
if fraction[1] == "/":
try:
num = int(fraction[0])
den = int(fraction[2])
if num < den:
print(f"{num}/{den} is a proper fraction")
else:
if num% den == 0
print(f"{num}/{den} is an improper fraction and can be reduced to {num/den}")
else:
print(f"{num}/{den} is an improper fraction and can be reduced to {num//den} + {num - (den * (num//den))}/{den}")
except ValueError:
print("numerator and denominator must be integer numbers")
Explanation:
The try and except statement of the python program is used to catch value error of the input fraction of values that are not number digits. The program converts the numerator and denominator string values to integers and checks for the larger value of both.
The program prints the fraction as a proper fraction if the numerator is lesser and improper if not.
Thanks for using our platform. We're always here to provide accurate and up-to-date answers to all your queries. We appreciate your time. Please revisit us for more reliable answers to any questions you may have. Keep exploring Westonci.ca for more insightful answers to your questions. We're here to help.