Question: Rewrite the following program fixing all the errors and using try / except statements to handle all potential runtime errors. def try _ except _

Rewrite the following program fixing all the errors and using try/except statements to handle all potential runtime errors.
def try_except_ex():
num1=input("enter a value:")
num2=int(input("Enter a value:"))
div=num1/num2
print(f"{num1}/{num2}={div}')
If the errors is due to wrong value, set num1=0 and num2=1 for use in calculating div ans display "One of the values entered is not an integer, Setting values to 0 and 1". If the error is due to division by zero, set div to"infinity". Use two try/except statements. The statement to display result should be outside of the try/except statements.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!