Re: [Tutor] Dividing 1 by another number ?

2005-01-31 Thread Alan Gauld
> What Alan meant, presumably, was this: > > one = 1 > other = 42 > result = float(one)/other Whoops! Yes indeedy! Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Dividing 1 by another number ?

2005-01-30 Thread Kent Johnson
Brandon wrote: PI = 3.14 Incidentally the math module has a more accurate value for pi: >>> import math >>> math.pi 3.1415926535897931 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

RE: [Tutor] Dividing 1 by another number ?

2005-01-30 Thread Tony Meyer
> In that case you need it to use floating point numbers. > The easiest way is to use 1.0 but if it comes from a table > or user entry you might have to explicitly convert: > > one = 1 > other = 42 > result = float(one/other) What Alan meant, presumably, was this: one = 1 other = 42 result = fl

Re: [Tutor] Dividing 1 by another number ?

2005-01-30 Thread Alan Gauld
> The archives of the list are available here: > > > And on ActiveState's web site they are even searchable! Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Dividing 1 by another number ?

2005-01-30 Thread Alan Gauld
> I'm trying to write a program they may involve needing to > divide 1 by another number. In that case you need it to use floating point numbers. The easiest way is to use 1.0 but if it comes from a table or user entry you might have to explicitly convert: one = 1 other = 42 result = float(on

RE: [Tutor] Dividing 1 by another number ?

2005-01-30 Thread Tony Meyer
> btw is there a place I can read everyones questions, > like I posted, or does this work my emailing a few > knowledgable people? The archives of the list are available here: (The messages from the future at the top are obviously ones where people's m

Re: [Tutor] Dividing 1 by another number ?

2005-01-30 Thread Terry Carroll
On Sun, 30 Jan 2005, Brandon wrote: > I'm trying to write a program they may involve needing to divide 1 by > another number. In the program below when I use 4 for the diameter of > the bore, and 1 for the diameter of the rod, and 60 for the PSI, the > force should be 706.8 . However the program k

Re: [Tutor] Dividing 1 by another number ?

2005-01-30 Thread Sean Perry
Tony Meyer wrote: Dividing two integers will give you an integer (truncated) result: If you want '1/2' to give you 0.5 (throughout your script), you can do: from __future__ import division Notice that '//' (with or without the from __future__ import) will give you the integer result. or more simply

RE: [Tutor] Dividing 1 by another number ?

2005-01-30 Thread Tony Meyer
> I'm trying to write a program they may involve > needing to divide 1 by another number. In the > program below when I use 4 for the diameter of > the bore, and 1 for the diameter of the rod, > and 60 for the PSI, the force should be 706.8 . > However the program keeps giving me 0 for "rodarea".