NEWB: dividing numbers

Chris Rebert clp2 at rebertia.com
Mon Mar 9 00:21:12 CET 2009


On Sun, Mar 8, 2009 at 3:08 PM, Lo <graga at congstar.de> wrote:
> I just tried python first time.
>
> 2/3
>
> the result is zero
>
> I want the result to be .333...
>
> How do I get this?

Add the following to the top of your program:

from __future__ import division

That tells Python to use the proper kind of division, which is now the
default in Python 3.0.

Cheers,
Chris

-- 
I have a blog:
http://blog.rebertia.com



More information about the Python-list mailing list