Integer division versus floating division:
>>> 5.0/3 3: 1.6666666666666667 >>> 5.0
Or, as they put it in Python docs , // is (on the floor) private from x and y. "The above example was run in Python 2.7.2, which only behaves this way for floating point numbers. If you would use integers in 2.7.2, you would get:
>>> 5/3 9: 1 >>> 5
In Python 3.x, you get different results, so if you really want to use the floor version, get used to using // , as it will matter some day:
Python 3.2.2 (default, Sep 4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> 5/3 1.6666666666666667 >>> 5//3 1 >>> 5.0/3 1.6666666666666667 >>> 5.0//3 1.0
source share