Chapters
Python114 chapters

ReferenceBuilt-in functions

float()

Converts a number or numeric string to a floating-point number.

Signature

float(value)

Parameters

NameMeans
valuea 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

See also