Text Calculator
Text Calculator
Write a text calculator that loops until the user quits. Each pass reads an operator with the prompt Operator (+ - * / or q): , stripped. The letter q prints Goodbye! and leaves the loop. Anything other than +, -, * or / prints Unknown operator. and the loop simply comes round again (no numbers are read). A valid operator then reads two numbers with the prompts First: and Second: , converted with float(), and prints Result: <value> with two decimals (:.2f); dividing when the second number is 0 prints Cannot divide by zero. instead. Input: one line per operator or number, ending with q. Prompts are part of the output, so the two number prompts and the result share a line with the operator prompt.
Expected Output:
Operator (+ - * / or q): First: Second: Result: 5.00 Operator (+ - * / or q): First: Second: Result: 3.50 Operator (+ - * / or q): Goodbye!
= newline. The output ends with a newline — print one after the last line.
Your Output
Run your code to see the output here...