Answered step by step
Verified Expert Solution
Link Copied!

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 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

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_2

Step: 3

blur-text-image_3

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

Building The Data Lakehouse

Authors: Bill Inmon ,Mary Levins ,Ranjeet Srivastava

1st Edition

1634629663, 978-1634629669

More Books

Students also viewed these Databases questions