Types of Numbers

There are three types used to represent numbers in Python; these are integers types, floating point numbers and complex numbers.

  1. Integers or int are whole numbers that do not need to have a fractional element
  2. Real numbers are represented as floating point numbers (or floats) which involves representing the digits before and after the decimal point
  3. Complex numbers are an extension of real numbers in which all numbers are expressed as a sum of a real part and an imaginary part. Python has built-in support for complex numbers, which are written using the engineering notation; that is the imaginary part is written with a j suffix, e.g. 3 + 1j.


All integer values, no matter how big or small are represented by the integer (or int) type in Python 3. For example:

x = 3
x =

Above code will produce output as,

<class 'int'>
<class 'int'>

This makes it very easy to work with integer numbers in Python. Unlike some programming languages such as C# and Java have different integer types depending on the size of the number and conversions need to be done from small to large numbers in some situations.

Floating Point Numbers

Real numbers, or floating point numbers, are represented as floats in Python.

Python represents floating point numbers using a decimal point to separate the whole part from the fractional part of the number, for example:

fuel_price = 75.99
print(fuel_price )
print(type(fuel_price ))

Above code snippet produces output as,

<class 'float'>

Complex Numbers in Python

A complex number is defined by a real part and an imaginary part and has the form a + bi (where i is the imaginary part and a and b are real numbers):

complex number in python

The letter ‘j’ is used in Python to represent the imaginary part of the number, for example:

real_number = 1j
img_number = 2j
print('real_number :', real_number, ', img_number :', img_number )

Above code snippet produces output as,

real_number: 1j , img_number: 2j
<class 'complex'>

Boolean Values

Python supports another type called Boolean; a Boolean type can only be one of True or False (and nothing else).

Note that these values are True (with a capital T) and False (with a capital F); true and false in Python are not the same thing and have no meaning on their own.

The equivalent of the int or float class for Booleans is bool.

The following example illustrates storing the two Boolean values into a variable all_ok:

all_ok = True
all_ok = False

Above code snippet produces output as,

<class 'bool'>

None Value

Python has a special type, the None Type, with a single value, None.

This is used to represent null values. It is not the same as False, or an empty string or 0; it is a non-value. It can be used when you need to create a variable but don’t have an initial value for it. None type can be tested using ‘is’ and ‘is not’, for example:

winner = None
print(winner is None)
print(winner is not None)

Above code snippet produces output as,



In this article, we saw about integers, floating point, complex numbers, boolean and a special type as None in Python.