Question: i. Write a program to accept only negative integers and print them onto the screen. The program should throw an exception if the input is

i. Write a program to accept only negative integers and print them onto the screen. The program should throw an exception if the input is zero. (hint: use try and Catch block )

ii. Write an example Exception handling code which uses ValueError Exception. Discuss the situation when using a ValueError is better than Exception.

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!