Data types as defined in our Top 20 Programming Terms that Everyone Should Know article are the means to identify the types of data used in a programming language. With the help of data types, we can identify the type of data and then perform associated operations for handling that type of data.

Python has five standard data types:

  1. Numbers
  2. String
  3. List
  4. Tuple
  5. Dictionary

Numbers in Python

In Python, everything is an object hence Python has a separate numbers class and all the integer and real numbers are objects in Python. Python’s number data types store numeric values. Since the number is an object in python it is created once you assign a value to them.

Python supports the following different number types:

  1. int (integers)
  2. float (floating point value)
  3. complex (complex numbers)

Integers are the numbers without any decimal values. They are either positive or negative integer values.
Example: 23, -10, -100, 35, etc.

Float or floating values are the real numbers. They consist decimal values and can be either positive or negative float values.
Example: 10.5, 29.15, -19.7, -12.3, 12.3 + e18, etc.

A complex number consists of an ordered pair of real numbers in which both of them are of type float denoted by x + yj, where x and y are the real numbers and j is the imaginary unit.
Examples: 3+5j, 3.5j, 4e+21j

These are the numbers type that Python3 supports. There is also some built-in function that Python supports along with these numbers. You can implement some of them directly on our variable others need to import a module called math in order to execute. So here is the list of most common built-in functions that operate on numbers.

Built-in Functions

1) abs() for getting the absolute value as a result. In mathematics, absolute value means a scalar distance of that particular number on the number line from 0. Since it is a scalar distance, therefore, the direction from zero has no meaning. Example: abs(15) is 15, abs(-74) is 74, abs(3+4j) is 5.0

2) pow() is used to perform the power based operation. The syntax of this built-in function is pow(number, raised_to_this_number), therefore this function needs two numbers as an argument. Example: pow(3,2) will give 9, pow(4,3) will give 64

3) round() is used to round up a floating point number. It is useful to round the numbers into a readable floating number when there are a lot of digits after a decimal point. It is also useful in situations where a perfect round figure is necessary for example when dealing with money.

The function round() also takes two numbers as parameters, round(number, decimal_place_to_round). Example: round(1.3458732,3) will round to 1.346

4) complex() is a built-in function useful in creating a complex number. The function takes in two arguments first one will denote real part and the second will denote the imaginary part of the complex number. The syntax is complex( real, imaginary ). Examples: complex(3,4) will give 3 + 4j

5) conjugate() function returns the conjugate of the given complex number. For example: x = 5 + 6j then x.conjugate() will return 5 – 6j. The function conjugate() doesn’t take any arguments.

Akarsh Singh
Follow me

Akarsh Singh

Founder, Code in Python. Web and Android App Developer. He loves Python and wants to share his knowledge via this website. Follow him on Facebook, Twitter and Github.
Akarsh Singh
Follow me

Latest posts by Akarsh Singh (see all)