+ 1
what is the output of this code ? print(int(1+2-3*4/5%6)) explain working
1 Answer
+ 1
Because of operator precedence, you should start with 3 * 4, that's probably where you went wrong.
3 * 4 == 12
12 / 5 == 2.4
2.4 % 6 == 2.4
1 + 2 == 3
3 - 2.4 == 0.6
int() makes floats into integers, so that it ignores decimal points, so 0.6 -> 0