As of 2020, India recorded as many as 8.2 million Python developers and the number is increasing every passing day. The TIOBE Index for July 2021 further revealed that globally, Python was the third-most popular programming language. Chances of it becoming the #1 programming language was high with Python’s leadership in data mining and artificial intelligence.

What are data structures?

As the name suggests, data structures hold data in the form of structures or code. In other words, data helps store collections of related data or information. Data structures are mostly used to modify, navigate and access information. They are critical in building real-life applications. To increase the efficiency of the programme, and reduce computational time, one must be aware of which data structures fit their present solutions.

Python has four in-built data structures:

  • Lists or Array
  • Dictionaries
  • Tuples
  • Sets
  • List

These array-like structures allow developers to store data of different types in a sequential manner. For every element in a list, a unique address– called Index, is assigned.

To create a list, one has to use square brackets and add the element inside of it, accordingly. The elements can be added using the append(), extend(), and insert() functions. An empty list will produce an empty output.

There are other functions that can be used while working with lists:

  • len() function returns the length of the list
  • index() returns the index value of the value passed
  • count() finds the count of the value passed
  • sorted() and sort() sort the values of the list
  • append() to add an item to the end of the list
  • clear() to clear all items from a list


Linear data structure queue stores data in the first-in-first-out format. That is, unlike lists, a programmer cannot access elements by index. They can only extract the next oldest ement, making it usable for order-sensitive tasks such as online order processing or voicemail storage.

One can, however, use append() and pop() to implement a queue. Insert and delete operations in queues are called enqueue and dequeue. Queues are used for operations on shared resources such as a printer or CPU core, or to serve as temporary storage for batch systems.


Stacks are collections of objects supporting last-in-first-out semantics for inserts and deletes. The linear data structures are built using array structures. However, unlike arrays or lists, stacks do not allow random access to objects.

Adding elements to a stack is called push and removing is called pop. Push operations use the append() method, and pop operations use pop().

Stacks are used in language parsing, reversing words, for undo mechanisms in editors and for runtime memory management.


These are basically pictorial representations of objects. Graph data structures represent the visual relationship between data vertices or nodes of a graph. Links connected to the vertices are called edges and are used to store data. Usually edges do not indicate the direction of flow between vertices. Directed graphs, like in linked lists, define the direction of relationship.

Graphs are usually used to convey visual web-structure networks in the form of code. They are used by Google Maps and Uber. Additionally, graphs are used to model social networking sites such as Facebook.

In Python, graphs are best implemented using dictionaries.

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Editor @ DevStyleR