I went to do a calculation in Python 2.7 and I was scared to see the result:
val = 1 / 16
print(val); # 0
Example on IDEONE
That is, when we make a division where the number divided is less than the divisor, the result returned is zero.
-
How do I get the result in
float
? -
Why does Python behave this way?