Literals

There are four built-in numeric types: integers, long integers, floating-point numbers, and complex numbers.

A number such as 1234 is interpreted as a decimal integer. To specify octal and hexadecimal integers, precede the value with 0 or 0x, respectively— 0644 or 0x100fea8. Write a long integer using a trailing l (ell) or L character, as in 1234567890L. Unlike integers, which are limited by machine precision, long integers can be of any length (up to the maximum memory of the machine). Numbers such as 123.34 and 1.2334e+02 are interpreted as floating-point numbers. An integer or floating-point number with a trailing j or J, such as 12.34J, is an imaginary number. You can create complex numbers with real and imaginary parts by adding ...

Get Python Essential Reference, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.