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)

modify this code into a postfix evaluator with no parenthesis in the arithmetic expression.  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) def pop(self): return self.list.pop() def peek (self): return self.list[-] def

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

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!