off topic but please forgive me me and answer

Tim Chase python.list at tim.thechases.com
Thu Apr 1 20:49:43 EDT 2010


David Robinow wrote:
> $ python -c "print 1/2 * 1/2"
> 0
> 
>  But that's not what I learned in grade school.
> (Maybe I should upgrade to 3.1?)

That's because you need to promote one of them to a float so you 
get a floating-point result:

   >>> 1/2 * 1/2
   0
   >>> 1/2 * 1/2.0
   0.0

Oh...wait ;-)

-tkc






More information about the Python-list mailing list