Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions

Question

=+Which pays a higher average return?

Answered: 1 week ago