[Tutor] eval and floating point

jadrifter jadrifter at gmail.com
Thu Jan 15 03:33:06 CET 2009


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 ("3./2."), but is there any way to do it with
> just ("3/2")?

That's not the eval function returning that integer so much as it is
Python itself.  You might try:
eval ("1.0 * 3/2")



More information about the Tutor mailing list