def evaluate(expression):
op_stack  = deque() <EOL>out_stack = deque() <EOL>tokens = parse(expression) <EOL>for token in tokens:<EOL><INDENT>if numeric_value.match(token):<EOL><INDENT>out_stack.append(float(token))<EOL><DEDENT>elif token == '<STR_LIT:(>':<EOL><INDENT>op_stack.append(token)<EOL><DEDENT>elif token == '<STR_LIT:)>':<EOL><INDENT>while len(op_stack) > <NUM_LIT:0> and op_stack[-<NUM_LIT:1>] != '<STR_LIT:(>':<EOL><INDENT>apply_operation(op_stack, out_stack)<EOL><DEDENT>op_stack.pop() <EOL><DEDENT>else: <EOL><INDENT>while len(op_stack) > <NUM_LIT:0> and is_operator(op_stack[-<NUM_LIT:1>]) and higher_priority(op_stack[-<NUM_LIT:1>], token):<EOL><INDENT>apply_operation(op_stack, out_stack)<EOL><DEDENT>op_stack.append(token)<EOL><DEDENT><DEDENT>while len(op_stack) > <NUM_LIT:0>:<EOL><INDENT>apply_operation(op_stack, out_stack)<EOL><DEDENT>return out_stack[-<NUM_LIT:1>]<EOL>
Calculate result of expression

expression String: The expression
type Type (optional): Number type [int, float]