Write a python program that does the
following:
Prompts the user for three numbers in one request.
Be sure to specify the “delimiter” by which a user enters those
three numbers.
Divides the first number by the second number and add that result
to the third number.
Prints output that shows in one line the formula applied and the
result of the calculation.
Validate input by:
• Checking the user entered 3 values
• Appropriately checking for the following errors: ValueError and ZeroDivisionError.
• Printing descriptive error messages to the console if validation fails.
No Example Output provided for this question.
The code given below takes the inputs and outputs the result for valid input.Its displays appropriate errors for zero division and improper inputs
values=input("Enter three space separated numbers: ").split()
if len(values)!=3:
print(f"ValueError! {len(values)} numbers found, Please enter three numbers")
else:
a=int(values[0])
b=int(values[1])
c=int(values[2])
while (b<= 0): #keep on taking input for second number until its equal to 0
b = int(input("ZeroDivisionError! Please enter a valid denominator: "))
result = a/b + c
print("The result of the formula a/b + c = ",result)
-----------------------------------------------------------------------------------------
Do upvote if you liked the solution. happy learning!
Get Answers For Free
Most questions answered within 1 hours.