Very basic question

Aaron Brady castironpi at gmail.com
Tue Dec 23 11:48:39 CET 2008


On Dec 23, 4:46 am, Sengly <Sengly.H... at gmail.com> wrote:
> Hello all,
>
> I would like to calculate a string expression to a float. For example,
> I have ('12/5') and I want 2.4 as a result. I tried to use eval but it
> only gives me 2 instead of 2.5
>
> Help!!!
>
> Regards,
>
> Sengly

>>> float('12')/float('5')
2.3999999999999999
>>> print float('12')/float('5')
2.4
>>> float(12/5)
2.0
>>> print float(12/5)
2.0



More information about the Python-list mailing list