Integer Division
Terry Reedy
tjreedy at udel.edu
Fri Jun 19 12:01:52 EDT 2009
Anjanesh Lekshminarayanan wrote:
>>>> a = 1
>>>> b = 25
>>>> a / b
> 0
>>>> float(a) / b
> 0.040000000000000001
>
>>>> from __future__ import division
>>>> a = 1
>>>> b = 25
>>>> a / b
> 0.040000000000000001
>
> In what simple way can I get just 0.04 ?
Short answer: use 3.1:
>>> 1//25
0
>>> 1/25
0.04
;-)
But you should really try to understand the answers others gave.
tjr
More information about the Python-list
mailing list