Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 labpy code implements a simple command line calculator that runs in the shell similar to what you may have created in lab Unfortunately, this calculator raises an exception and traceback when the following inputs are used:
Enter left operand:
Enter right operand:
What type of calculation would you like to perform x
and
Enter left operand:
Enter right operand:
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 tryexcept 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started