Top 7 Data Types of Python | Python Data Types

Data types are an essential concept in the python programming language. In Python, every value has its own python data type. The classification of data items or to put the data value into some sort of data category is called Data Types. It helps to understand what kind of operations can be performed on a value. If you are a beginner and interested to learn more about data science, check out our data science certification from top universities.

In the Python Programming Language, everything is an object. Data types in Python represents the classes. The objects or instances of these classes are called variables. Let us now discuss the different kinds of data types in Python. 

Built-in Data Types in Python

  • Binary Types: memoryview, bytearray, bytes
  • Boolean Type: bool
  • Set Types: frozenset, set
  • Mapping Type: dict
  • Sequence Types: range, tuple, list
  • Numeric Types: complex, float, int
  • Text Type: str

Our learners also read – free online python course for beginners!

1. Python Numbers

We can find complex numbers, floating point numbers and integers in the category of Python Numbers. Complex numbers are defined as a complex class, floating point numbers are defined as float and integers are defined as an int in Python. There is one more type of datatype in this category, and that is long. It is used to hold longer integers. One will find this datatype only in Python 2.x which was later removed in Python 3.x. 

“Type()” function is used to know the class of a value or variable. To check the value for a particular class, “isinstance()” function is used. 

Must read: Data structures and algorithms free course!

  • Integers:
    • There is no maximum limit on the value of an integer. The integer can be of any length without any limitation which can go up to the maximum available memory of the system. 
  • Integers can look like this:
    • >>> print(123123123123123123123123123123123123123123123123123 + 1)


  • Floating Point Number:
    • The difference between floating points and integers is decimal points. Floating point number can be represented as “1.0”, and integer can be represented as “1”. It is accurate up to 15 decimal places.
  • Complex Number:
    • “x + yj” is the written form of the complex number. Here y is the imaginary part and x is the real part.

2. Python List

An ordered sequence of items is called List. It is a very flexible data type in Python. There is no need for the value in the list to be of the same data type. The List is the data type that is highly used data type in Python. List datatype is the most exclusive datatype in Python for containing versatile data. It can easily hold different types of data in Python.  

It is effortless to declare a list. The list is enclosed with brackets and commas are used to separate the items. 

A list can look like this:

>>> a = [5,9.9,’list’]

One can also alter the value of an element in the list.

3. Python Tuple

A Tuple is a sequence of items that are in order, and it is not possible to modify the Tuples. The main difference list and tuples are that tuple is immutable, which means it cannot be altered. Tuples are generally faster than the list data type in Python because it cannot be changed or modified like list datatype. The primary use of Tuples is to write-protect data. Tuples can be represented by using parentheses (), and commas are used to separate the items. 

Tuples can look like this:

>>> t = (6,’tuple’,4+2r)

In the case of a tuple, one can use the slicing operator to extract the item, but it will not allow changing the value.  Data Frames in Python

Explore our Popular Data Science Courses

upGrad’s Exclusive Data Science Webinar for you –

4. Python Strings

A String is a sequence of Unicode characters. In Python, String is called str. Strings are represented by using Double quotes or single quotes. If the strings are multiple, then it can be denoted by the use of triple quotes “”” or ”’. All the characters between the quotes are items of the string.

One can put as many as the character they want with the only limitation being the memory resources of the machine system. Deletion or Updation of a string is not allowed in python programming language because it will cause an error. Thus, the modification of strings is not supported in the python programming language.

A string can look like this:

>>> s = “Python String”

>>> s = ”’a multi-string

Strings are also immutable like tuples and items can be extracted using slicing operators [].

If one wants to represent something in the string using quotes, then they will need to use other types of quotes to define the string in the beginning and the ending.

Such as: 

>>> print(“This string contains a single quote (‘) character.”)

This string contains a single quote (‘) character.

>>> print(‘This string contains a double quote (“) character.’)

This string contains a double quote (“) character.

Our learners also read: Excel online course free!

5. Python Set

The Collection of Unique items that are not in order is called Set. Braces {} are used to defined set and a comma is used to separate values. One will find that the items are unordered in a set data type.

Duplicates are eliminated in a set and set only keeps unique values. Operations like intersection and union can be performed on two sets. 

Python set will look like this:

>>> a = {4,5,5,6,6,6}

>>> a 

{4, 5, 6}

The slicing operator does not work on set because the set is not a collection of ordered items, and that is why there is no meaning to the indexing of set. Python Developer Tools

Read our popular Data Science Articles

6. Python Dictionary

Dictionary is a type of python data type in which collections are unordered, and values are in pairs called key-value pairs. This type of data type is useful when there is a high volume of data. One of the best functions of Dictionaries data type is retrieving the data for which it is optimized. The value can only be retrieved if one knows the key to retrieve it. 

Braces {} (curly brackets) are used to define dictionaries data type in Python. A Pair in the dictionary data type is an item which is represented as key:value. The value and the key can be of any data type.

Python Dictionary can look like this:

>>> d = {3:’key’,4:’value’}

7. Boolean Type

There can be only two types of value in the Boolean data type of Python, and that is True or False. 

It can look like this:

>>> type(True)

<class ‘bool’>

>>> type(False)

<class ‘bool’>

The true value in the Boolean context is called “truthy”, and for false value in the Boolean context, it is called “falsy”. Truthy is defined by the objects in boolean, which is equal to True, and in the same way, Falsy is defined by the objects equal to falsy. One can also evaluate Non-Boolean objects in a Boolean context.

Top Data Science Skills to Learn in 2022


If you are reading this article, you are probably learning Python or trying to become a Python developer. We hope this article helped you learn about the data types in Python. 

If you’re interested to learn python & want to get your hands dirty on various tools and libraries, check out Executive PG Program in Data Science.

In Python, do we need to specify data types?

Unlike statically typed languages like C or Java, Python does not need the data type of a variable to be declared explicitly. The interpreter in dynamically typed languages like Python guesses the data type of the Python variable depending on the kind of value supplied to it.

In Python, what is the difference between a set and a list?

Lists and tuples are Python data structures for storing values in a sequential order. Sets are another common Python data structure for storing values. The main distinction between sets and lists or tuples is that sets, unlike lists or tuples, cannot have multiple instances of the same element and cannot hold data in any order. The list is sorted and can include the same items as the set, but the set is unordered and contains distinct elements.

Are arrays in Python quicker than lists?

Python Lists are slower than NumPy Arrays. A collection of homogenous data types stored in contiguous memory regions is referred to as an array. A list, on the other hand, is a collection of disparate data types stored in non-contiguous memory regions in Python. Because ArrayList utilizes a set quantity of array, an array is quicker. When you add another entry to the ArrayList, however, it overflows. It generates a new Array and duplicates all of the elements from the previous one.

Want to share this article?

Prepare for a Career of the Future

Leave a comment

Your email address will not be published. Required fields are marked *

Leave a comment

Your email address will not be published. Required fields are marked *

Get Free career counselling from upGrad experts!
Book a session with an industry professional today!
No Thanks
Let's do it
Get Free career counselling from upGrad experts!
Book a Session with an industry professional today!
Let's do it
No Thanks