Numbers

Integers

Decimal: 123 
Octal: 0123
Hexadecimal: 0x123

Long integers

  • Append an uppercase (or lowercase) "L" to the number.
  • There is no fundamental size limit for long integers.
  • Integers and long integers are unified starting from release 2.2 (the L suffix is no longer required).

Floating-point numbers

  • aka "Floats"
  • In "e" notation, the integer and exponent are always decimal values.
3.14
10.
.001
1e100
3.14e-10

Imaginary numbers

123j
123J
  • Append a lowercase (or uppercase) letter "j" to a float.

Complex numbers

123+456j 
  • Complex literals are represented by combining a float and an imaginary number.
  • To extract the real and imaginary parts, use the "real" and "imag" methods.
x = 123+456j
print x.real, x.imag