Easy Tutorial
❮ Ref Math Erfc Python Stdlib ❯

Python float() Function

Python Built-in Functions


Description

The float() function is used to convert integers and strings to floating-point numbers.

Syntax

Syntax for the float() method:

class float([x])

Parameters

Return Value

Returns a floating-point number.

Examples

The following examples demonstrate the use of float():

>>> float(1)
1.0
>>> float(112)
112.0
>>> float(-123.6)
-123.6
>>> float('123')     # String
123.0

Python Built-in Functions

❮ Ref Math Erfc Python Stdlib ❯