Ad
  • Custom User Avatar

    The given expression can be broken down to x = expr1, where expr1: 13 + y = 3 + 1 due to the operator '=''s lower prescedence compare to '+'.
    Again, expr1: expr2 = expr3 where expr2: 13 + y, expr3: 3 + 1. Both expr2 and expr3 are valid expressions if y is already assigned.
    However, even if expr2 could be resolved, expr1 would end up being an invalid expression, since '=' operator only takes an identifier on the left-hand side.

    tl;dr: the expression should cause an error.

  • Custom User Avatar

    Oh I didn't see the problem is for py2, thank you for the correction.
    In py2 though, eval() function would work the same as py3 if the test generator gives floating numbers.

  • Custom User Avatar

    After struggling for hours, figured out that python (2.7 in my case, but probably for all versions if it uses the same test code) test case is totally wrong.
    It uses eval(expression) to calculate the given expression, however the expression is all chosen with randint function.
    In other words, input expression would always only contains integers, so that eval always rounds off decimals.
    If you want to pass the random tests for now, just use integers, negelecting floating numbers.

  • Custom User Avatar

    Can confirm this. python random tests are just not right. Mainly related to the rounding, it seems like.