How can I parse a numeric string to its corresponding float value?



Python’s number conversion function float() converts an integer to float with fractional part as 0. It also parses a string with valid representation of float number to a float object.

>>> float('1.11')
1.11
>>> float(1)
1.0
>>> float('1')
1.0
>>> float('1.1e-2')
0.011


Updated on: 2020-02-25T11:22:35+05:30

155 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements