Question: def _ getPostfix ( self , txt ) : ' ' ' Required: _ getPostfix must create and use a Stack for expression processing >

def _getPostfix(self, txt):
'''
Required: _getPostfix must create and use a Stack for expression processing
>>> x=Calculator()
>>> x._getPostfix('2^4')
'2.04.0^'
>>> x._getPostfix('2')
'2.0'
>>> x._getPostfix('2.1*5+3^2+1+4.45')
'2.15.0*3.02.0^+1.0+4.45+'
>>> x._getPostfix('2*5.34+3^2+1+4')
'2.05.34*3.02.0^+1.0+4.0+'
>>> x._getPostfix('2.1*5+3^2+1+4')
'2.15.0*3.02.0^+1.0+4.0+'
>>> x._getPostfix('(.5)')
'0.5'
>>> x._getPostfix ('((2))')
'2.0'
>>> x._getPostfix ('2*((5+-3)^2+(1+4))')
'2.05.0-3.0+2.0^1.04.0++*'
>>> x._getPostfix ('(2*((5+3)^2+(1+4)))')
'2.05.03.0+2.0^1.04.0++*'
>>> x._getPostfix ('((2*((5+3)^2+(1+4))))')
'2.05.03.0+2.0^1.04.0++*'
>>> x._getPostfix('2*(-5+3)^2+(1+4)')
'2.0-5.03.0+2.0^*1.04.0++'
# In invalid expressions, you might print an error message, adjust doctest accordingly
# If you are veryfing the expression in calculate before passing to postfix, this cases are not necessary
>>> x._getPostfix('2*5+3^+-2+1+4')
>>> x._getPostfix('2*5+3^*2+1+4')
>>> x._getPostfix('25')
>>> x._getPostfix('25+')
>>> x._getPostfix('2*(5+3)^2+(1+4')
>>> x._getPostfix('2*(5+3)^2+)1+4(')
>>> x._getPostfix('2*5%+3^+-2+1+4')
'''
# YOUR CODE STARTS HERE
postfixStack = Stack()# method must use postfixStack to compute the postfix expression
pass

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 Programming Questions!