Python data Structures – List, Set, Dict, Tuples in Python

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

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.
Example

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

Individual Tuple elements extracting data structures in python:

element
If you use “0” it will be start count from beginning
element
If you use “-1” it will be start to count from End
element
If you use “1:3” it will be start count from between

Basic operation in Tuple data structures

Finding Length of Tuple:

length

Concatenating Tuples:

Concatenating

Repeating Tuple Elements:

Repeating and Concatenating:

Repeating

Tuple maximum and Minimum functions

maximum
Maximum Value
minimum
Minimum Value

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.

Example

Basic operation in Python list function

Changing the element at “0” Index

list in python

Appending a new element

list python

Popping the last element

list in python

Reversing elements of list

list in python

Inserting element at a specified index

list in python

Sorting a list

list in python

Concatenating Lists

list in python

Repeating elements

list in python

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.

Example

Extracting Dictionary keys and Values

“.keys” function use to print
“.values” Function use to print

Python Dictionary Basic Modification function

Adding a new element

Changing an existing element

Update one Dictionary’s elements with another

Popping an element

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
Example: Duplicates are not allowed in set

Python Set Basic Modification function

Update one Dictionary’s elements with another

python set

Updating multiple elements

python set

Removing an element

python set

Union of two sets

set python

Intersection of two sets

set python

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)

Rate this post
Sharing Is Caring:

1 thought on “Python data Structures – List, Set, Dict, Tuples in Python”

Leave a Comment