+ 2
I am not able to understand what's going on here
print(-11//3) and the answer is. -4 How's that possible. That's why Python is weird.
5 Respuestas
+ 3
Divide 11 by 3 you will get quotient as 3.6 but if you do floor division of 11 by 3 you’ll get 3 as result just because floor division removes the digits after the decimal point.
But if either of 11 or 3 is negative then in simple division you’ll get -3.6 but in floor division the answer will be floored and rounded away from zero and the final result will be -4.
+ 2
Prashant Kumar, // in Python stands for floor division. That is, the quotient you get from the division is rounded *down* to the nearest integer.
Which means, floor division (//) travels towards the left of the number line.
In your problem, (-11/3) = -3.6.
Rounding it down gives -4
Therefore, (-11//3) = -4. ___(Ans.)
Hope it helps. 😊