Re: [Tutor] eval and floating point

2009-01-15 Thread wesley chun
>>> eval("float(3/2)") >> >> That still does not work, because the 'float' comes after the >> division. 3/2 equals 1, so float(3/2) equals 1.0. To make it work, >> you'll have to put the float inside the division: >> eval("float(3)/2") correct. as long as one of the operands is a float, the divisi

Re: [Tutor] eval and floating point

2009-01-15 Thread Alan Gauld
"Andre Engels" wrote eval("float(3/2)") That still does not work, because the 'float' comes after the division. 3/2 equals 1, so float(3/2) equals 1.0. To make it work, you'll have to put the float inside the division: eval("float(3)/2") Ahem! Quite. That was what I actually intended to p

Re: [Tutor] eval and floating point

2009-01-15 Thread Andre Engels
On Thu, Jan 15, 2009 at 1:08 PM, Alan Gauld wrote: > > "Mr Gerard Kelly" wrote > >> I've noticed that the eval() function gives an integer, so eval("3/2") >> gives back 1. float(eval("3/2")) doesn't seem to work, any way to get a >> floating point number back with eval()? > > Move the float insid

Re: [Tutor] eval and floating point

2009-01-15 Thread Alan Gauld
"Mr Gerard Kelly" wrote I've noticed that the eval() function gives an integer, so eval("3/2") gives back 1. float(eval("3/2")) doesn't seem to work, any way to get a floating point number back with eval()? Move the float inside the eval: eval("float(3/2)") It's nothing to do with eval b

Re: [Tutor] eval and floating point

2009-01-15 Thread Senthil Kumaran
On Thu, Jan 15, 2009 at 9:42 AM, Bill Campbell wrote: > Python does the Right Thing(tm) when dividing two integers, > returning an integer result. > Unless it is python 3k, in which integer division (single /) can result in float. Because int is a long by default. :-) -- Senthil __

Re: [Tutor] eval and floating point

2009-01-14 Thread Bill Campbell
On Wed, Jan 14, 2009, jadrifter wrote: >On Thu, 2009-01-15 at 12:19 +1000, Mr Gerard Kelly wrote: >> Thanks very much >> >> I've noticed that the eval() function gives an integer, so eval("3/2") >> gives back 1. float(eval("3/2")) doesn't seem to work, any way to get a >> floating point number bac

Re: [Tutor] eval and floating point

2009-01-14 Thread jadrifter
On Thu, 2009-01-15 at 12:19 +1000, Mr Gerard Kelly wrote: > Thanks very much > > I've noticed that the eval() function gives an integer, so eval("3/2") > gives back 1. float(eval("3/2")) doesn't seem to work, any way to get a > floating point number back with eval()? > > I know you can just do ("

Re: [Tutor] eval and floating point

2009-01-14 Thread Vern Ceder
Mr Gerard Kelly wrote: Thanks very much I've noticed that the eval() function gives an integer, so eval("3/2") gives back 1. float(eval("3/2")) doesn't seem to work, any way to get a floating point number back with eval()? I know you can just do ("3./2."), but is there any way to do it with jus

Re: [Tutor] eval and floating point

2009-01-14 Thread Jervis Whitley
On Thu, Jan 15, 2009 at 1:19 PM, Mr Gerard Kelly wrote: > Thanks very much > > I've noticed that the eval() function gives an integer, so eval("3/2") > gives back 1. float(eval("3/2")) doesn't seem to work, any way to get a > floating point number back with eval()? > > I know you can just do ("3.

[Tutor] eval and floating point

2009-01-14 Thread Mr Gerard Kelly
Thanks very much I've noticed that the eval() function gives an integer, so eval("3/2") gives back 1. float(eval("3/2")) doesn't seem to work, any way to get a floating point number back with eval()? I know you can just do ("3./2."), but is there any way to do it with just ("3/2")? __