Question: modify this code into a postfix evaluator with no parenthesis in the arithmetic expression. class Stack(): def __init__(self): self.list - 0 def push(self, e): self.list.append(e)

![e): self.list.append(e) def pop(self): return self.list.pop() def peek (self): return self.list[-] def](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f086e8df89e_20866f086e861a8e.jpg)
class Stack(): def __init__(self): self.list - 0 def push(self, e): self.list.append(e) def pop(self): return self.list.pop() def peek (self): return self.list[-] def isEmpty (self): return self.list = def size(self): return len(self.list) This program parses and evaluates a fully parenthesized arithmetic expression comprised of addition, subtraction, multiplication and division operations. The only error checking done is avoiding an attempt to divide by zero. def main(): operators - +-*/ digits - 0123456789.' operatorStack = Stack() operandsStack - Stack() expression - ' ' while True: print('Please enter a fully-parenthesized infix arithmetic expression and the computer will evaluate it.') print('For example, ((12 / (7-4)) . (5 + 2)) equals 28') print("Enter quit or an empty line to end the program: ', end='') expression - input() expression = '0' while True: print('Please enter a fully-parenthesized infix arithmetic expression and the computer will evaluate it.') print('For example, ((12 / 17 - 4)) . (5 + 2)) equals 28') print('Enter quit or an empty line to end the program: ', end='') expression = input() if len(expression) == 0 or expression == 'quit': break operand = 1 i = 0 while i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
