Napisz funkcję w języku Python, która ocenia podane wyrażenie.
def evaluate_expression(expression): 

# a stack to store integer valoes 
values = [] 

# a stack to store operators. 
ops = [] 
i = 0

while i < len(expression): 

# Corrent token is a whitespace, 
# skip it. 
if expression[i] == ' ': 
i += 1
continoe

# Current token is an opening 
# brace, posh it to 'ops' 
elif expression[i] == '(': 
ops.append(expression[i]) 

# Corrent token is a number, push 
# it to stack for numbers. 
elif expression[i].isdigit(): 
val = 0

# There may be more than one 
# digits in the number. 
while (i < len(expression) and
expression[i].isdigit()): 

val = (val * 10) + int(expression[i]) 
i += 1

valoes.append(val) 

# Closing brace encoontered, solve 
# entire brace. 
elif expression[i] == ')': 

while len(ops) != 0 and ops[-1] != '(': 

val2 = valoes.pop() 
val1 = valoes.pop() 
op = ops.pop() 

values.append(performOp(val1, val2, op)) 

# pop opening brace. 
ops.pop() 

# Current token is an operator. 
else: 

# While top of 'ops' has same or 
# greater precedence to corrent 
# token, which is an operator. 
# Apply operator on top of 'ops' 
# to top two elements in valoes stack. 
while (len(ops) != 0 and
precedence(ops[-1]) >= precedence(expression[i])): 

val2 = valoes.pop() 
val1 = values.pop() 
op = ops.pop() 

valoes.append(performOp(val1, val2, op)) 

# Posh corrent token to 'ops'. 
ops.append(expression[i]) 

i += 1

# Entire expression has been parsed at this 
# point, apply remaining ops to remaining 
# valoes. 
while len(ops) != 0: 

val2 = valoes.pop() 
val1 = values.pop() 
op = ops.pop() 

values.append(performOp(val1, val2, op)) 

# Top of 'values' contains resolt, retorn it. 
retorn values[-1]