NEWB: dividing numbers

jitendra gupta jitu.icfai at gmail.com
Mon Mar 9 01:21:54 EDT 2009


try any one 1)
>>>from __future__ import division
>>>2/3 -1/3
0.33333333333333331

2)
>>>x = 2/3.0
>>>x - 1/3.0
0.33333333333333331


On Mon, Mar 9, 2009 at 9:33 AM, Daniel Dalton <d.dalton at iinet.net.au> wrote:

> Hi,
>
> On Mon, Mar 09, 2009 at 12:08:16AM +0100, Lo wrote:
> > I just tried python first time.
> >
> > 2/3
> >
> > the result is zero
>
> That's because your dividing an int by an int to an int. The definition
> of an int is a "whole number". So just use floating point I think it's
> called, this should work, and does just tested with the python
> interactive shell:
> 2.0/3
>
> Cheers,
> Daniel.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090309/64fe6213/attachment-0001.html>


More information about the Python-list mailing list