
Data Structures are the simple structures to hold our data. These structures are helpful in performing some operations on our data like storing, managing, accessing etc.,
The basic data structure of the python includes the List ,Tuples , Sets and Dictionaries.
Python Lists :
Python lists will hold data inside the square brackets [] and are arranged in a sequential manner separated by comma. The List can store different types of values including lists by itself.
The Lists are MUTABLE, means the values can be changed after assigning the values to it.
We will check some operations on the Lists below:
In order to store data into the List structure, we need to declare the list first and we can able to do many operations on the lists datastructure.
Declaring a Lists:
# Declaring a variable my_list and storing different data into it my_List = [L1,L2,03,[53]]
Accessing a Lists:
A lists can be accessed by positive indexing as well as negative Indexing. The lists stores the value starting with zero,one and so on.
my_List[3] # will print [53], accessing the 4th value(53) in the list
The following are the methods to perform some operations on the list values.
1. Finding the length of the list – len()

2. List Append – Appending will add a value at the end of the list
3. List Extend – Extend also adds value at the end, but there is small difference when we try to add list values.
4. List Insert – Inserts the value at the specified index, as the insert method takes two parameters. One is the location another is an value to insert.
5. List Remove – Like the other methods, we use remove() method to remove the value from list , and we can use pop() method to do the same.
6. List Sorting – In list we can use the sorted() method to sort the elements of the list.
7. List Reverse – This will return the elements of the list in reverse order.

8. List Looping – we will now loop the elements in the list, using for loop and in operator.

9. List Slicing – Segmenting a part of the list is known as Slicing, The slicing operation can be performed by indexing.

TEST YOURSELF:
Q1) What is the difference between delete, remove and pop methods in python lists?
Use the methods and explore the difference in the methods by yourself and have fun 🙂
Python Tuples :
Tuples operate in the same way as Lists, the only difference is that the tuple elements are enclosed in the paranthesis() and Immutable (Elements cannot be changed once it is assigned).
Let’s see an example for immutable property of the tuple.

TEST YOURSELF:
Q2) How come satish replaces value of 6 in the tuple? Do check and comment below, awaiting for your answers 🙂

Q3) From the above example, we could see the type of t is str, what we have to actually do to get type as “Tuple”? Do check and comment below 🙂
Python Sets:
Till now, we checked the sequential data structures [Lists and Tuples] in python. The sets in python are the unordered collection of unique items as there will not be any duplicates.
The set is Mutable and are enclosed in the curly braces {}.
The following are the creation of set in python.

We add elements to the set by add() method and using update() method. Sets will not support indexing operation in python
As the name suggests, we can perform mathematical operations on sets like Union, Intersection, Difference etc.., Why don’t you try and perform some operations 🙂

The elements from the sets are remove using remove(), discard(), delete(),pop() methods.
Special Type of Set : Frozen Sets
A special type of set called frozenset can be used, in which the elements in the frozenset are immutable same as in the python tuples.
Being immutable, it does not support add() method.

Python Dictionary:
The python dictionary is an unordered collection of items, which contains not only values also the key and value pair.
The following are the methods for the dictionary creation.

Accessing the Dict Values:
We can access the dict values by using keys or the get method. The only difference is that, Using get() method will return None if the key is not present in the dictionary otherwise it returns an key error.

The following are the methods in the python dictionary.

Can u guess the output for values() method?
Hope you enjoy reading my blog, looking forward for your answers and comments below
Bye and Take care, Let’s meet in the next blog:)

