Question: For this lab your goal will be to modify a program that calculates two operands given the supplied operator. The program that you must modify

For this lab your goal will be to modify a program that calculates two operands given the supplied operator. The program that you must modify can be downloaded from here Download here.
The lab2.py code implements a simple command line calculator that runs in the shell (similar to what you may have created in lab 1). Unfortunately, this calculator raises an exception and traceback when the following inputs are used:
Enter left operand: 5
Enter right operand: 0
What type of calculation would you like to perform (+,-, x,/)?/
and
Enter left operand: 5.0
Enter right operand: 10
What type of calculation would you like to perform (+,-, x,/)?*
These inputs are not the only values that can cause an exception, but they demonstrate the two different types of exceptions that go unhandled in the current code. You must modify the program so that these conditions no longer raise exceptions.
You are free to fix the calculator however you want, but you must complete the following requirements:
Identify and handle two different types of exceptions using try/except statements.
Organize your code so the program will notify the user of the error and continue accepting input.

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!