Python float() Function
The Python float() function returns floating point number. float() takes a number or string (which can be converted into number) as input parameter and return floating point number.
Syntax
float(value)
Parameters
value |
Required. A number or string which can be converted into number. |
Example:
In the example below, float() function returns floating point number.
MyNumber = 10 print(float(MyNumber)) MyNumber = 10.555 print(float(MyNumber)) MyString = "50.555" print(float(MyString))
The output of the above code will be:
10.0 10.555 50.555
❮ Python Built-in Functions