Python float() Function
Description
float()The function is used to convert integers and strings into floating-point numbers.
Syntax
float() method syntax:
class float([x])
Parameters
- x -- integer or string
Return Value
Returns a floating-point number.
Examples
The following example demonstrates the usage of float():
>>>float(1)
1.0
>>> float(112)
112.0
>>> float(-123.6)
-123.6
>>> float('123') # String
123.0
Python Built-in Functions