Course Recommendation:

Example

Python float() Function

Convert the number 5 to a float:

Run Instance

x = float(5)

Definition and Usage

float() converts the specified value to a float.

Syntaxvaluefloat(

)

Parameter Description
value Numbers or strings that can be converted to a float.

More Examples

Example

Convert String to Float:

x = float("3.1415")

Run Instance