Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. Modify a given interactive calculator python program to handle exception errors. You start by downloading a python program Calculator_noExcept.py) from Canvas. The program should

2. Modify a given interactive calculator python program to handle exception errors. You start by downloading a python program Calculator_noExcept.py) from Canvas. The program should run without modification. (make sure it works, save a copy, and begin to make the change (one at a time) ) The program does not handle exception errors well. Your focuses are on formula-related errors. a. Number of elements for the formula (must be 3) b. The 1st and 3rd elements must be a number c. The operator (2nd element) must be one of (+, -, *, /) For this interactive program, a user enters the inputs in a formula format that consists of a number, an operator (eg +, -, *, /), and another number, separated by white space. For example for 3+2, user must enter 3 + 2 (not 3+2). The program has a custom error type (FormulaError(Exception)) to capture formula-related errors. Your task is to raise the FormulaError type error when an error occurs. There are two methods, parse_input(user_input), and calculate(n1, op, n2), that could potentially raise formula-related errors. You want to handle the errors by the caller. The program uses .split( ) to separate the string into three parameters. Split user input using str.split(), and check whether the resulting list is valid: If the input is valid, perform the calculation and print out the result. The program prompts the user to enter new inputs repeatably (>>>) until the user enters

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions