Answer:
You can add a validation routine. This will check whether or not the user has entered the correct value.
Step-by-step explanation:
Step 1: Look at the Python program properly :
numerator = int(input("Enter a numerator: "))
denominator = int(input("Enter denominator: "))
if ((numerator / denominator) * denominator) == numerator:
print("Divides evenly!")
else:
print("Doesn't divide evenly.")
Step 2: Add the validation routine:
if denominator == 0:
print("Error - Invalid Denominator")
else:
...
Step 3: Add the routine into the program:
numerator = int(input("Enter a numerator: "))
denominator = int(input("Enter denominator: "))
if denominator == 0:
print("Error - Invalid Denominator")
else:
if ((numerator / denominator) * denominator) == numerator:
print("Divides evenly!")
else:
print("Doesn't divide evenly.")
- Educator