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: 25-Feb-2020

67 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements