• Srujan kachhwaha

Python Built-in Data Structures, Store And Organise Your Variables Hussle-Free

Updated: Jul 25

In the last post, we discussed how to install python on your machine and get started.

Here, We will discuss the built-in data structures python provide us to make our programming easy.

Data structures provide us an organized way to store the data. It is very important to think about how we will be going to store the data and variables that our program is using.

This helps us to access those data easily when we need them. Every program should be organized and follow a certain pattern or path to store its variables and data.

Let's understand this with an example, Suppose we create a program to store the latest movie titels.

Now, this statement 'to store latest movie' tells us that anything which arrives new, should at the top of the list.

Now, what data structure should we use then? that will allow us to fetch say top 10 latest movie titles?

Stack is the answer! What's a stack? Do you see an old pile of books you have in your house, the Pile always has recent used books right! That's the concept of our stack!


Stack is a linear data structure that always has the recent or the latest item inserted in it at the top.

The main point of all the theories above is to tell you that why data structures are important. They define the flow of data or variables in our program.

Python Data Structures

  • List

  • Tuples

  • Dictionary

List In Python

The list in python look something like this:

>>>l = []
>>> l = [1,2,3,4]
>>> [1,2,3,4]

Tuples In Python

Tuples in Python are a special data structure. They are immutable after they are created. immutable means you can not change them, once you create them.

They are linear data structures like lists, but they are immutable.

>>> t = (1,2,3,4)
>>> t

Dictionaries In Python

Dictionaries in python allow us to store variables in the form of key: value pairs. To access any variable within the data structure you need to pass its key.

>>> d = {"hey":"Hello", 1: 2}
>>> d["hey"]

These three are built-in data structures python provides us. With these built-in data structures, comes a handful of built-in python functions that will help us implement and play with these structures at ease.

We will dive deep into each of these data structures and their built-in functions with examples and theories. For now, let's windup here. See you on the next post.

21 views0 comments

Recent Posts

See All