ReferenceBuilt-in functions
float()
Converts a number or numeric string to a floating-point number.
Signature
float(value)Parameters
| Name | Means |
|---|---|
value | a number or a string holding one |
Returns
A float. Raises ValueError on text that is not a number.
Example
Python
print(float("3.5"))
print(float(7))
print(float("1e3"))Output
3.5 7.0 1000.0