What is Python data Structures ?
List, Set, Tuples, and Dictionary these are four basic Python data Structures. There are almost cover Eighty percent of our real world data structures. Each of the data structures is unique and have own way to organizing.
The Python Data structures are fundamental constructs around which you build in your programs. that can be accessed more efficiently depending upon the situation. Python fundamental helps to learn of these data structures in a very simpler way as compared to other programming languages.
![Python data Structures](https://utechnoworld.com/wp-content/uploads/2022/02/Python-data-Structures-1024x576.jpg)
In this blogs, we will discuss about Python Data Structures in the Python Programming Language. We will discuss all the in-built data structures like list tuples, set, dictionary etc and also some advanced data structures like Stack, Linked List etc.
Queries Solved:
- What is Tuples in python ?
- Tuple elements extracting
- Basic operation in Tuple data structures
- Tuple maximum and Minimum functions
- What is list in python ?
- Basic operation in Python list function
- What is Dictionary python ?
- Extracting Dictionary keys and Values
- What is Set Python ?
- Python Set Basic Modification function
What is Tuples in python ?
Tuple in Python is used to store multiple items in a single variable with sequence of immutable Python objects and the value of the items stored in the tuple cannot be changed. The tuple() function is a built-in function in Python data Structures that can be used to create a tuple.
![tuple in python data structure.](https://utechnoworld.com/wp-content/uploads/2022/02/tuple-in-python.png)
In above consequence you can not modify a tuple in python data structures because it is immutable. as a example if you try to replace “True” by “hello” in this tuple function showing type error : “tuple” object does not support item assignment.
![tuple in python data structure](https://utechnoworld.com/wp-content/uploads/2022/02/tuple-in-python-data-structure.png)
Individual Tuple elements extracting data structures in python:
![element](https://utechnoworld.com/wp-content/uploads/2022/02/element1.png)
![element](https://utechnoworld.com/wp-content/uploads/2022/02/element2.png)
![element](https://utechnoworld.com/wp-content/uploads/2022/02/element3.png)
Basic operation in Tuple data structures
Finding Length of Tuple:
![length](https://utechnoworld.com/wp-content/uploads/2022/02/length.png)
Concatenating Tuples:
![Concatenating](https://utechnoworld.com/wp-content/uploads/2022/02/concat.png)
Repeating Tuple Elements:
![](https://utechnoworld.com/wp-content/uploads/2022/02/repeating.png)
Repeating and Concatenating:
![Repeating](https://utechnoworld.com/wp-content/uploads/2022/02/repeat.png)
Tuple maximum and Minimum functions
![maximum](https://utechnoworld.com/wp-content/uploads/2022/02/max.png)
![minimum](https://utechnoworld.com/wp-content/uploads/2022/02/min.png)
What is list in python ?
Python data structure a list is a mutable, or changeable, ordered sequence of elements. That are used to store multiple items in a single variable. Each of the element that is inside of a list is called an item. List is a compound data type, means you can have different-2 data types under a list, as a example we can have integer, float and string items in a same list.
![](https://utechnoworld.com/wp-content/uploads/2022/02/list-in-python.png)
Basic operation in Python list function
Changing the element at “0” Index
![list in python](https://utechnoworld.com/wp-content/uploads/2022/02/element1-1.png)
Appending a new element
![list python](https://utechnoworld.com/wp-content/uploads/2022/02/element2-1.png)
Popping the last element
![list in python](https://utechnoworld.com/wp-content/uploads/2022/02/element3-1.png)
Reversing elements of list
![list in python](https://utechnoworld.com/wp-content/uploads/2022/02/element4.png)
Inserting element at a specified index
![list in python](https://utechnoworld.com/wp-content/uploads/2022/02/element4-1.png)
Sorting a list
![list in python](https://utechnoworld.com/wp-content/uploads/2022/02/element6.png)
Concatenating Lists
![list in python](https://utechnoworld.com/wp-content/uploads/2022/02/element7.png)
Repeating elements
![list in python](https://utechnoworld.com/wp-content/uploads/2022/02/element-8.png)
What is Dictionary python ?
It is the mutable Python data-structure That is used to store the data in a key-value pair format. The data type in Python, which can simulate the real-life data arrangement where some specific value exists for some particular key. The Dictionary in python are written with curly brackets ({}), including key-value pairs separated by commas (,). A colon (:) separates each key from its value.
![](https://utechnoworld.com/wp-content/uploads/2022/02/Dictionary-python-1.png)
Extracting Dictionary keys and Values
![](https://utechnoworld.com/wp-content/uploads/2022/02/keys-1.png)
![](https://utechnoworld.com/wp-content/uploads/2022/02/keys1.png)
Python Dictionary Basic Modification function
Adding a new element
![](https://utechnoworld.com/wp-content/uploads/2022/02/adding.png)
Changing an existing element
![](https://utechnoworld.com/wp-content/uploads/2022/02/replace-1.png)
Update one Dictionary’s elements with another
![](https://utechnoworld.com/wp-content/uploads/2022/02/update.png)
Popping an element
![](https://utechnoworld.com/wp-content/uploads/2022/02/popping.png)
What is Set Python ?
The python data structures Set is an unordered and unindexed collection of elements that one of 4 built-in data types in Python. A set object contains one or more items, not necessarily of the same type (Duplicates are not allowed in set ), which are separated by a enclosed and comma in curly brackets {}. The following defines a python set object with even numbers.
![set python](https://utechnoworld.com/wp-content/uploads/2022/02/set-python.png)
Python Set Basic Modification function
Update one Dictionary’s elements with another
![python set](https://utechnoworld.com/wp-content/uploads/2022/02/set-1.png)
Updating multiple elements
![python set](https://utechnoworld.com/wp-content/uploads/2022/02/set-2.png)
Removing an element
![python set](https://utechnoworld.com/wp-content/uploads/2022/02/set-3.png)
Union of two sets
![set python](https://utechnoworld.com/wp-content/uploads/2022/02/set4.png)
Intersection of two sets
![set python](https://utechnoworld.com/wp-content/uploads/2022/02/set5.png)
1. Beginner Python Programming with examples (Part 1)
- What is a Variable in Python?
- What are the data types in Python?
- What are the different types of data in Python?
- What are operators in Python?
- What is Arithmetic Operators?
- What is Logical Operators?
- What is Relation Operator ?
- Beginner Python Practical Example:-
2. Beginner Python Programming with examples (Part 2)
- What is Python Tokens ?
- Keywords
- Identifiers
- Literals
- Operators
- What is string Functions?
1 thought on “Python data Structures – List, Set, Dict, Tuples in Python”