Question: In python, how can I use stack inside a function for a calculator program? ps: I coded all the functions, but I just need help

In python, how can I use stack inside a function for a calculator program?In python, how can I use stack inside a function for a

ps: I coded all the functions, but I just need help for the calc function(the last one).

Example of expression is: 2*(4+2*(5+3^2)+1)+4

Then, use the stack to find an innermost pair of parentheses. Calculate the inside by _calc

class stack: class node: defint (self): def Jen (self) def push,self, yal): #It adds a new node including VA, at the top pointer def pop (self): def def exRx(self, numl, gRR, num2): return numl+num2 edit, opp-"-". return numi-num2 edit, opp-'' * " : return numi*num2 if num20: print("zero division error: exeR") return "zero division error: exeopr else: return numlum2 return numl ** num'2 else: print("fatal internal error in exeopE") return "fatal internal error in eXet?; def cale(expr): # copy the body of Gale(expr) of HW2 def cale(expr) # Required: Gale must create a stack to substantially use it for parenthesis matching # Call-Gale to computer the inside parentheses class stack: class node: defint (self): def Jen (self) def push,self, yal): #It adds a new node including VA, at the top pointer def pop (self): def def exRx(self, numl, gRR, num2): return numl+num2 edit, opp-"-". return numi-num2 edit, opp-'' * " : return numi*num2 if num20: print("zero division error: exeR") return "zero division error: exeopr else: return numlum2 return numl ** num'2 else: print("fatal internal error in exeopE") return "fatal internal error in eXet?; def cale(expr): # copy the body of Gale(expr) of HW2 def cale(expr) # Required: Gale must create a stack to substantially use it for parenthesis matching # Call-Gale to computer the inside parentheses

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!