Integers are numbers without a decimal point. Integers in Python including positive, 0 and
negative integers. Python has only one type of integer and Python integers have an infinite range of values
then Python can handle them easily, no matter the size of value.
#Assign 63 to the variable n (use anaconda)
n = 63
print (type (n))
#Assign a large integer to x
x = 9999999999999999999999
print (type (x))
#Assign a small integer to y
y = -9999999999999999999999
print (type (y))
x is a very large number while y is a very small number. Python can output it correctly which
means that Python’s ability to handle integers is very powerful. No matter how big or small integers, Python
uses only one type for storage, which is integer.
Different Forms of Python Integers
In Python, integers can be represented in multiple formats:
Normally, usual integer is the decimal form, which is composed of a total of ten numbers from 0 to 9.
Note that integers in decimal form cannot start with 0 unless the value itself is 0.
It consists of only two numbers, 0 and 1. Normally it is written as 0b or 0B.
An octal form consists of eight digits, from 0 to7. Normally it is written as 0o or 0O.
Note that integers in decimal form cannot start with 0 unless the value itself is 0..
It consists of ten numbers from 0 to 9 and six letters from A to F (or a to f). When writing,
it starts with 0x or 0X.
To easier user to read the number, Python 3.x allows the underscore (_) as a separator for
numbers (including integer and decimals). The values of the number itself do not affect by the
separator – underscores (_). It is like commas in English numbers. The underscore replaces commas in
click = 11_311_547
distance = 283_000_000
print ("Python Tutorial Reading:", click)
print ("The distance between the A and B:", distance)
The output is:
Python Tutorial Reading: 11311547 The distance between the A and B: 283000000
Detailed explanation on Python decimal/ float type
In programming languages, decimals point number are usually stored as floating-point numbers.
Floating-point and fixed-point numbers are opposite: if the decimal point moves during storage,
it is called a floating-point number; if the decimal point does not move, it is called a
What is the writing format of decimals in Python?
To include a decimal point when writing decimals, otherwise Python will treat them as integer.
The example of decimal format: 35.6, 356.0, and 0.356.
It means a numeric form involving exponents. For example: 2.3E6, 3.8E-3, etc. If it is written
in exponential format, it is considered as a decimal type even if its final value looks like an integer.
C language has two types of decimals, they are float and double type. Float type can store a small range
of decimals while double can store a large range of decimals.
But Python has only one decimal type, which is float type. Let’s refer to the following example of
decimals type in Python:
Conclusion: From the result, Python can accommodate very small and very large floating-point numbers. When
printing out the floating-point numbers, some numbers are rounded up/ down based on the length or size
of the floating-point numbers. The value of f_5 is 120 000, but it is still a decimal type but not an
The result of f_6 supposed to be 12.3 * 0.1 = 1.23. But the output of print result is not accurate. This is
because decimals are stored in binary form in memory. The numbers after the decimal point is likely to be
a series of infinite loop numbers when converted to binary form. Thus, it cannot calculate the number
Detailed explanation on Python complex type
Complex type is a built-in type in Python, you do not have to import any Python packages. In other words,
Python programming language supports complex type without relying on any third party libraries.
A complex number consists of a real part and an imaginary part. In Python, the imaginary part of complex
number is suffixed by j or J. The format is: