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

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!