Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
The given expression can be broken down to
x = expr1
, whereexpr1: 13 + y = 3 + 1
due to the operator'='
's lower prescedence compare to'+'
.Again,
expr1: expr2 = expr3
whereexpr2: 13 + y
,expr3: 3 + 1
. Bothexpr2
andexpr3
are valid expressions ify
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.
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.
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.
Can confirm this. python random tests are just not right. Mainly related to the rounding, it seems like.