Discover answers to your questions with Westonci.ca, the leading Q&A platform that connects you with knowledgeable experts. Explore thousands of questions and answers from a knowledgeable community of experts on our user-friendly platform. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts.
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.
Thank you for your visit. We are dedicated to helping you find the information you need, whenever you need it. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Get the answers you need at Westonci.ca. Stay informed with our latest expert advice.