how to convert an integer to a float?

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Tue Feb 27 19:18:28 EST 2007


yinglcs, you can use float() or the new division:

>>> 1 / 2
0
>>> 1 / float(2)
0.5
>>> from __future__ import division
>>> 1 / 2
0.5

Bye,
bearophile




More information about the Python-list mailing list