Ask Your Question

Revision history [back]

If you choose to use exec, you can get the desired behavior by adding this line before it:

from __future__ import division

That uses Python 3 to treat the ratio of two integers as true division. More information:

http://stackoverflow.com/questions/575925/how-to-convert-rational-and-decimal-number-strings-to-floats-in-python https://www.python.org/dev/peps/pep-0238/

If you choose to use exec, you can get the desired behavior by adding this line before it:

from __future__ import division

That uses Python 3 to treat the ratio of two integers as true division. More information:

http://stackoverflow.com/questions/575925/how-to-convert-rational-and-decimal-number-strings-to-floats-in-python http://stackoverflow.com/questions/575925/how-to-convert-rational-and-decimal-number-strings-to-floats-in-python

https://www.python.org/dev/peps/pep-0238/