In python 2.7, the / operator is an integer division if the input is integers.
If you want to split the floats (which I always prefer), just use this special import:
from __future__ import division
See it here:
>>> 7 / 2 3 >>> from __future__ import division >>> 7 / 2 3.5 >>>
Integer division is achieved using // , and modulo using %
>>> 7 % 2 1 >>> 7
EDIT
As user2357112 commented, this import must be done before any other regular import.
bgusach Jan 23 '14 at 19:01 2014-01-23 19:01
source share