Language Syntax

Floating point literal — Python syntax

A decimal point or exponent denotes a float. The stored binary floating-point value may approximate the written decimal number; exponent notation uses powers of ten. Hexadecimal float notation is parsed by float.fromhex, not ordinary literal syntax.

Formal Syntax & Structure

python syntaxpython
1.25 | .5 | 5. | 2e3

Return Value

float

Value obtained by evaluating this expression; see description for context and constraints.

Working Example

Example Snippetpython
a=.5b=2e3print((a,b,0.1+0.2==0.3))
Python Reference