def arithm_expr_eval(cell, expr):
    """Evaluates a given expression

    :param expr: expression
    :param cell: dictionary variable name -> expression

    :returns: numerical value of expression

    :complexity: linear
    """
    if isinstance(expr, tuple):
        (left, op, right) = expr
        lval = arithm_expr_eval(cell, left)
        rval = arithm_expr_eval(cell, right)
        if op == '+':
            return lval + rval
        if op == '-':
            return lval - rval
        if op == '*':
            return lval * rval
        if op == '/':
            return lval // rval
    elif isinstance(expr, int):
        return expr
    else:
        cell[expr] = arithm_expr_eval(cell, cell[expr])
        return cell[expr]
def arithm_expr_eval ( cell , expr ) : if isinstance ( expr , tuple ) : ( left , op , right ) = expr lval = arithm_expr_eval ( cell , left ) rval = arithm_expr_eval ( cell , right ) if op == '+' : return lval + rval if op == '-' : return lval - rval if op == '*' : return lval * rval if op == '/' : return lval // rval elif isinstance ( expr , int ) : return expr else : cell [ expr ] = arithm_expr_eval ( cell , cell [ expr ] ) return cell [ expr ]
Evaluates a given expression

    :param expr: expression
    :param cell: dictionary variable name -> expression

    :returns: numerical value of expression

    :complexity: linear