I remembered the day when I made up my mind to learn python then the very first things I learned about data types and data structures. So in this article, I would like to discuss different data structures in python.

So initially, what is data structures? in a simple world, it is a structure that can hold data, where data refers to a different type of data and related data. overall it is the concept of organizing and storing data so it can be accessed easily and work efficiently.

The different types of data structures available in Python are listed below.

  1. List
  2. Tuple
  3. Set
  4. Dictionary

We will start with List and see the different operations we can do with List. The List is a Mutable data structure in Python that means after the list is created we can perform data manipulations on it like the update, delete, insert operations.

We can simply create a list of numbers with below syntax.

Image for post

Not only numbers we can store string, decimals in the list. we can modify the list also.

Image for post

So, we are able to store data in a list, now the question comes how to access those elements of data?.

We can access those elements by their index number. To fetch the first element of data we need to use the below syntax.

Image for post

Similarly, we can get the second, the third element as required. Now we want to see the last element in a list. We can do this in two methods.

The first method is using the length method to identify the length of the list.

Image for post

Using length we can find the last index number by subtracting 1 from the length.

#python #data-science #data-structures

Data Structures in Python.
5.25 GEEK