Code in Python
Machine Learning and Deep Learning Blogs

Data types and Numbers in Python

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)


  1. Aw, this was an exceptionally nice post. Taking a few minutes and actual effort to make a great article… but what can I say… I hesitate a whole lot and never seem to get anything done.

  2. Hi there, I found your blog by way of Google at the same time as searching for a comparable topic, your website came up, it seems good. I’ve bookmarked it in my google bookmarks

  3. Hello there, You’ve done a fantastic job. I’ll certainly digg it and personally suggest to my friends. I am sure they’ll be benefited from this site.

  4. Excellent post. I will be dealing with many of these issues as well..

  5. Hey there! I know this is kind of off topic but I was wondering if you knew where I could get a captcha plugin for my comment form?
    I’m using the same blog platform as yours and I’m having
    trouble finding one? Thanks a lot!

  6. Hi my loved one! I want to say that this post is amazing, nice written and
    include approximately all important infos. I’d like
    to peer extra posts like this .

  7. Hi, this weekend is nice in favor of me, as this point
    in time i am reading this fantastic informative post here at
    my house.

  8. Remarkable issues here. I am very happy to peer your post.
    Thanks so much and I’m looking ahead to contact you.
    Will you please drop me a e-mail?

  9. This is a really good tip especially to those new to the blogosphere.
    Simple but very accurate info… Many thanks for sharing this one.
    A must read post!

Leave a Reply

Your email address will not be published.


© 2019 Code in Python