Question: 3 . You're going to write an interactive calculator! User input is assumed to be a formula that consist of a number, an operator (
You're going to write an interactive calculator! User input is assumed to be a formula that consist of a number, an operator at least and and another number, separated by white space eg Split user input using strsplit, and check whether the resulting list is valid:
If the input does not consist of elements, raise a FormulaError, which is a custom Exception. Try to convert the first and third input to a float like so:
floatvalue floatstrvalue Catch any ValueError that
occurs, and instead raise a FormulaError. If the second input is not or again raise a FormulaError. If the input is valid, perform the calculation and print out the result. The user is then prompted to provide new input, and so on until the user enters quit. Python Program
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
