Language Syntax

Numeric literal — Python syntax

Write integer, floating-point or imaginary values directly. A leading minus is a unary operator, not part of the numeric token; underscores can separate digits at permitted positions.

Formal Syntax & Structure

python syntaxpython
123 | 0xff | 1.25 | 2e3 | 4j

Return Value

int | float | complex

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

Working Example

Example Snippetpython
values=[0xff,1_000,2e3,4j]print([(type(v).__name__,v) for v in values])
Python Reference