sequences this is certainly very interestingalbeit shortprogram the eval function does an awful lot of work for us buthow does it workit turns out we can write our own eval function using couple of stacks in this section we describe an infix expression evaluator to make our job bit easierwe'll insist that the user enter spaces between all operators (including parensand operands so for instancethe user might interact as follows please enter an infix expression the result of the infix evaluator algorithm uses two stacksan operator stack and an operand stack the operator stack will hold operators and left parens the operand stack holds numbers the algorithm proceeds by scanning the tokens of the infix expression from left to right you can do this quite easily in python by splitting the input string and then iterating over the list of strings from the input the tokens are operators (including parensand numbers each operator has precedence associated with it multiplication and division operators have the highest precedence while addition and subtraction are next finally the left paren and right paren precedence are the lowest function called precedence can be written so that given an operatorthe precendence function returns the proper precedence value you can decide on your precedence values given the prescribed restrictions to begin the operand stack and the operator stack are initialized to empty stacks and left paren is pushed on the operator stack for each token in the input we do the following if the token is an operator then we need to operate on the two stacks with the given operator operating is described in sect if the token is number then we push it on the number stack after scanning all the input and operating when required we operate on the stacks one more time with an extra right paren operator after operating the final time the operator stack should be empty and the operand stack should have one number on it which is the result you pop the operand stack and print the number as your result the operate procedure the operate procedure should be separate function the operate procedure is given an operatorthe operator stackand operand stack as arguments to operate we do the followingif the given operator is left paren we push it on the operator stack and return otherwisewhile the precedence of the given operator is less than or equal to the precedence of the top operator on the operator stack proceed as followsthis copy belongs to 'acha