Basic calculator: evaluate an expression with + - * /.
Asked in the VO coding stage. From SWE question bank. Reported follow-up: Add support for parentheses.
Implement def calculate(expression):. The input is a valid string containing non-negative integers, spaces, and the operators +, -, *, and /. Return the integer result. Apply standard precedence, and truncate division toward zero. Parentheses are not included.
def calculate(expression):