Joined June 2013
·

Michele Lacchia

Student
·
Italy
·
·

Posted to Math and Int/Float in Python over 1 year ago

The problem is not math.ceil, but rather that in Python 2 division between integers. So if in Python 2 you do: 182 / 100 you actually get 1. In the second snippet ceil actually gets 1 as argument: it cannot convert the single numbers to floats because it gets the result as argument. You can avoid that (on Python 2) by adding at the top of the file:

from __future__ import division

and you would get what you would expect. This is the default in Python 3: 182 / 100 gives 1.82.

Achievements
89 Karma
0 Total ProTip Views