Question: Complete the following tasks in PYTHON: Write an exception handler to catch ValueError and output 'int ( ) : Input is not an integer. '

Complete the following tasks in PYTHON:
Write an exception handler to catch ValueError and output 'int(): Input is not an integer.'
Write an exception handler to catch ZeroDivisionError and output 'total_rainfall / num_months: Denominator cannot be zero.'
Example:
Ex: If the input is bread, then the output is:
int(): Input is not an integer.
Ex: If the input is 0, then the output is:
total_rainfall / num_months: Denominator cannot be zero.
Provided code:
try:
num_months = int(input())
total_rainfall =15.0
print(f'Average rainfall per month is {total_rainfall / num_months}')
# Your code goes here

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 Finance Questions!