"Mr Gerard Kelly" <s4027...@student.uq.edu.au> 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 but with Python. eval just asks the
interpreter to evaluate the string. Which is why you hardly ever
need to use eval, you can usually work with the string in your
own code and execute it that way.

Alan G


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to