In Python 2 /
returns only integer part if you use two integers - like int(0.8)
. You have to use float ie. float(a)
or 4.0
(shortly 4.
) or * 1.0
print float(4)/5
print 4/float(5)
print 4.0/5
print 4/5.0
print 4./5
print 4/5.
print a*1.0/b # sometimes you can see this method
print a/(b*1.0) # this version need () - without () you get (a/b)*1.0