Re: NEWB: dividing numbers

2009-03-08 Thread jitendra gupta
try any one 1) >>>from __future__ import division >>>2/3 -1/3 0.1 2) >>>x = 2/3.0 >>>x - 1/3.0 0.1 On Mon, Mar 9, 2009 at 9:33 AM, Daniel Dalton wrote: > Hi, > > On Mon, Mar 09, 2009 at 12:08:16AM +0100, Lo wrote: > > I just tried python first time. > > > > 2/3

Re: NEWB: dividing numbers

2009-03-08 Thread Daniel Dalton
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 d

Re: NEWB: dividing numbers

2009-03-08 Thread MRAB
Lo 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? That's integer division (integer divided by integer is integer). If you want the result to be floating point then make one of them floating point: 2.0 / 3 or do this

Re: NEWB: dividing numbers

2009-03-08 Thread Michal Wyrebski
Lo pisze: I just tried python first time. 2/3 the result is zero Float type must be specified explicitly: 2/3.0 or 2.0/3 In Python 3.x operators behave differently and '2/3' would give float number as a result. I want the result to be .333... Than try: 1/3.0 because 2/3.0 will never

Re: NEWB: dividing numbers

2009-03-08 Thread Chris Rebert
On Sun, Mar 8, 2009 at 3:08 PM, Lo 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 divisio

Re: NEWB: dividing numbers

2009-03-08 Thread Grant Edwards
On 2009-03-08, Lo wrote: > I just tried python first time. > > 2/3 > > the result is zero > > I want the result to be .333... How odd. > How do I get this? 1./3 -- Grant -- http://mail.python.org/mailman/listinfo/python-list

Re: NEWB: dividing numbers

2009-03-08 Thread Diez B. Roggisch
Lo schrieb: I just tried python first time. 2/3 the result is zero I want the result to be .333... Well, that's not going to happen - 2/3 is .666 if not done with integers... How do I get this? Use floating points. >>> 2.0 / 3.0 0.3 Diez -- http://mail.python.org/mailma

NEWB: dividing numbers

2009-03-08 Thread Lo
I just tried python first time. 2/3 the result is zero I want the result to be .333... How do I get this? Thanks a lot L -- http://mail.python.org/mailman/listinfo/python-list