SlideShare a Scribd company logo
DATA STRUCTURES
NAME: C. NIKHIL KUMAR
ROLL NUMBER: 22J21A0535
CLASS: CSE-A
SUBJECT : PYTHON
▪ Data structures in Python are containers that allow you to
store and organize data in a particular format.
▪ They provide efficient ways to perform operations such as
insertion, deletion, retrieval, and modification of data. Python
provides several built-in data structures, including:
✓ LISTS:
▪ Lists are ordered collections of items that can be of different
data types. They are mutable, meaning you can modify the
elements they contain.
▪ Lists are defined using square brackets ([]), and you can
access elements by their index.
▪ Example of creating python list:
List = [1, 2, 3, “GFG”, 2.3]
Print(List)
Output
[1, 2, 3, “GFG”, 2.3]
▪ List elements can be accessed by the assigned index. In python
starting index of the list, sequence is 0 and the ending index is N-1.
✓ TUPLES:
▪ Tuples are similar to lists, but they are immutable, meaning
their elements cannot be modified once defined.
▪ They are defined using parentheses (()) and can be accessed
using indexing.
▪ In python, tuples are created by placing a sequence of values
separated by ‘comma’ with or without the use of parentheses
for grouping of the data sequence.
▪ Example:
Tuple = (‘Geeks’ , ’For’)
print(“nTuple with the use of String:”)
print(Tuple)
Output:
(‘Geeks’ , ‘For)
✓ SETS:
▪ Sets are unordered collections of unique elements. They do not
allow duplicate values.
▪ Sets are defined using curly braces ({}) or the `set()` function.
You can perform set operations like union, intersection, and
difference.
SET IMPLEMENTATION:
✓ DICTIONARIES:
▪ Dictionaries are key-value pairs, where each value is associated
with a unique key. They are also known as associative arrays or
hash maps.
▪ Dictionaries are defined using curly braces ({}) with key-value
pairs separated by a colon (:).
▪ Indexing of python dictionary is done with the help of keys.
These are of any hashable type i.e. an object whose can never
change like strings, numbers, tuples, etc.
✓ ARRAYS:
▪ Arrays are used to store a fixed-size sequence of elements of the
same data type.
▪ Unlike lists, arrays can only contain elements of a single type. In
Python, arrays are available through the `array` module.
✓ LINKED LISTS:
▪ Linked lists are a dynamic data structure composed of nodes,
where each node contains data and a reference (or link) to the
next node in the sequence.
▪ Linked lists are not built-in Python data structures, but you can
implement them using classes and objects.
• A linked list is represented by a pointer to the first node of the
linked list. The first node is called the head. If the linked list is
empty, then the value of the head is NULL. Each node in a list
consists of at least two parts:
➢Data
➢Pointer (Or Reference) to the next node
✓ STACK:
▪ A stack is a Last-In-First-Out (LIFO) data structure, where
elements are added or removed from the top.
▪ Python provides an implementation of stacks using lists or you
can create your own using the `deque` class from the
`collections` module.
✓ QUEUE:
▪ A queue is a First-In-First-Out (FIFO) data structure, where
elements are added at the rear and removed from the front.
▪ Python provides implementations of queues using lists or you
can use the `Queue` class from the `queue` module.
QUEUE:
STRING
➢Python strings are arrays of bytes representing Unicode
characters.
➢In simpler terms, a string is an immutable array of characters.
➢Python does not have a character data type, a single character
is simply a string with a length of 1.
❖ PYTHON STRINGS OPERATIONS
String = "Welcome to NikhilArts"
print("Creating String: ")
print(String)
# Printing First character
print("nFirst character of String is: ")
print(String[0])
# Printing Last character
print("nLast character of String is: ")
print(String[-1])
❑OUTPUT:
Creating string:
Welcome to NikhilArts
First character of string is :
W
Last character of string is :
s
BINARY TREE
oA tree is a hierarchical data structure that looks like the
below figure –
o A binary tree is a tree whose elements can have almost two
children.
tree ---- j <-- root /  f k /   a h z <-- leaves
o Since each element in a binary tree can have only 2 children, we
typically name them the left and right children.
• Binary Tree node contains the following parts.
➢ Data
➢Pointer to left child
➢Pointer to the right child
Data structures in python

More Related Content

Similar to Data structures in python

Python Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptxPython Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptx
ShreyasLawand
 
13- Data and Its Types presentation kafss
13- Data and Its Types presentation kafss13- Data and Its Types presentation kafss
13- Data and Its Types presentation kafss
AliKhokhar33
 
DS.ppt Datatastructures notes presentation
DS.ppt Datatastructures notes presentationDS.ppt Datatastructures notes presentation
DS.ppt Datatastructures notes presentation
SakkaravarthiShanmug
 
11 Introduction to lists.pptx
11 Introduction to lists.pptx11 Introduction to lists.pptx
11 Introduction to lists.pptx
ssuser8e50d8
 
Python data structures (Lists and tuples) presentation
Python data structures (Lists and tuples) presentationPython data structures (Lists and tuples) presentation
Python data structures (Lists and tuples) presentation
VedaGayathri1
 
Chapter - 2.pptx
Chapter - 2.pptxChapter - 2.pptx
Chapter - 2.pptx
MikialeTesfamariam
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
sarala9
 
Python Data-Types
Python Data-TypesPython Data-Types
Python Data-Types
Akhil Kaushik
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
SaralaT3
 
Data structure study material introduction
Data structure study material introductionData structure study material introduction
Data structure study material introduction
SwatiShinde79
 
PM.ppt
PM.pptPM.ppt
data structure programing language in c.ppt
data structure programing language in c.pptdata structure programing language in c.ppt
data structure programing language in c.ppt
LavkushGupta12
 
intr_ds.ppt
intr_ds.pptintr_ds.ppt
intr_ds.ppt
PrakharNamdev3
 
data structure details of types and .ppt
data structure details of types and .pptdata structure details of types and .ppt
data structure details of types and .ppt
poonamsngr
 
PM.ppt
PM.pptPM.ppt
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptxQ-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
kalai75
 
Unit 1.ppt
Unit 1.pptUnit 1.ppt
Unit 1.ppt
Minakshee Patil
 
java.pdf
java.pdfjava.pdf
java.pdf
RAJCHATTERJEE24
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
Haitham El-Ghareeb
 
data structure in programing language.ppt
data structure in programing language.pptdata structure in programing language.ppt
data structure in programing language.ppt
LavkushGupta12
 

Similar to Data structures in python (20)

Python Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptxPython Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptx
 
13- Data and Its Types presentation kafss
13- Data and Its Types presentation kafss13- Data and Its Types presentation kafss
13- Data and Its Types presentation kafss
 
DS.ppt Datatastructures notes presentation
DS.ppt Datatastructures notes presentationDS.ppt Datatastructures notes presentation
DS.ppt Datatastructures notes presentation
 
11 Introduction to lists.pptx
11 Introduction to lists.pptx11 Introduction to lists.pptx
11 Introduction to lists.pptx
 
Python data structures (Lists and tuples) presentation
Python data structures (Lists and tuples) presentationPython data structures (Lists and tuples) presentation
Python data structures (Lists and tuples) presentation
 
Chapter - 2.pptx
Chapter - 2.pptxChapter - 2.pptx
Chapter - 2.pptx
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
Python Data-Types
Python Data-TypesPython Data-Types
Python Data-Types
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
Data structure study material introduction
Data structure study material introductionData structure study material introduction
Data structure study material introduction
 
PM.ppt
PM.pptPM.ppt
PM.ppt
 
data structure programing language in c.ppt
data structure programing language in c.pptdata structure programing language in c.ppt
data structure programing language in c.ppt
 
intr_ds.ppt
intr_ds.pptintr_ds.ppt
intr_ds.ppt
 
data structure details of types and .ppt
data structure details of types and .pptdata structure details of types and .ppt
data structure details of types and .ppt
 
PM.ppt
PM.pptPM.ppt
PM.ppt
 
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptxQ-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
 
Unit 1.ppt
Unit 1.pptUnit 1.ppt
Unit 1.ppt
 
java.pdf
java.pdfjava.pdf
java.pdf
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
 
data structure in programing language.ppt
data structure in programing language.pptdata structure in programing language.ppt
data structure in programing language.ppt
 

Recently uploaded

Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
wisnuprabawa3
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
gerogepatton
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
NazakatAliKhoso2
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
Las Vegas Warehouse
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
KrishnaveniKrishnara1
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
rpskprasana
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
mamamaam477
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
University of Maribor
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
IJNSA Journal
 

Recently uploaded (20)

Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
 

Data structures in python

  • 1. DATA STRUCTURES NAME: C. NIKHIL KUMAR ROLL NUMBER: 22J21A0535 CLASS: CSE-A SUBJECT : PYTHON
  • 2. ▪ Data structures in Python are containers that allow you to store and organize data in a particular format. ▪ They provide efficient ways to perform operations such as insertion, deletion, retrieval, and modification of data. Python provides several built-in data structures, including:
  • 3. ✓ LISTS: ▪ Lists are ordered collections of items that can be of different data types. They are mutable, meaning you can modify the elements they contain. ▪ Lists are defined using square brackets ([]), and you can access elements by their index.
  • 4. ▪ Example of creating python list: List = [1, 2, 3, “GFG”, 2.3] Print(List) Output [1, 2, 3, “GFG”, 2.3] ▪ List elements can be accessed by the assigned index. In python starting index of the list, sequence is 0 and the ending index is N-1.
  • 5. ✓ TUPLES: ▪ Tuples are similar to lists, but they are immutable, meaning their elements cannot be modified once defined. ▪ They are defined using parentheses (()) and can be accessed using indexing.
  • 6. ▪ In python, tuples are created by placing a sequence of values separated by ‘comma’ with or without the use of parentheses for grouping of the data sequence. ▪ Example: Tuple = (‘Geeks’ , ’For’) print(“nTuple with the use of String:”) print(Tuple) Output: (‘Geeks’ , ‘For)
  • 7. ✓ SETS: ▪ Sets are unordered collections of unique elements. They do not allow duplicate values. ▪ Sets are defined using curly braces ({}) or the `set()` function. You can perform set operations like union, intersection, and difference.
  • 9. ✓ DICTIONARIES: ▪ Dictionaries are key-value pairs, where each value is associated with a unique key. They are also known as associative arrays or hash maps. ▪ Dictionaries are defined using curly braces ({}) with key-value pairs separated by a colon (:).
  • 10. ▪ Indexing of python dictionary is done with the help of keys. These are of any hashable type i.e. an object whose can never change like strings, numbers, tuples, etc.
  • 11. ✓ ARRAYS: ▪ Arrays are used to store a fixed-size sequence of elements of the same data type. ▪ Unlike lists, arrays can only contain elements of a single type. In Python, arrays are available through the `array` module.
  • 12. ✓ LINKED LISTS: ▪ Linked lists are a dynamic data structure composed of nodes, where each node contains data and a reference (or link) to the next node in the sequence. ▪ Linked lists are not built-in Python data structures, but you can implement them using classes and objects.
  • 13. • A linked list is represented by a pointer to the first node of the linked list. The first node is called the head. If the linked list is empty, then the value of the head is NULL. Each node in a list consists of at least two parts: ➢Data ➢Pointer (Or Reference) to the next node
  • 14.
  • 15. ✓ STACK: ▪ A stack is a Last-In-First-Out (LIFO) data structure, where elements are added or removed from the top. ▪ Python provides an implementation of stacks using lists or you can create your own using the `deque` class from the `collections` module.
  • 16.
  • 17. ✓ QUEUE: ▪ A queue is a First-In-First-Out (FIFO) data structure, where elements are added at the rear and removed from the front. ▪ Python provides implementations of queues using lists or you can use the `Queue` class from the `queue` module.
  • 19. STRING ➢Python strings are arrays of bytes representing Unicode characters. ➢In simpler terms, a string is an immutable array of characters. ➢Python does not have a character data type, a single character is simply a string with a length of 1.
  • 20. ❖ PYTHON STRINGS OPERATIONS String = "Welcome to NikhilArts" print("Creating String: ") print(String) # Printing First character print("nFirst character of String is: ") print(String[0]) # Printing Last character print("nLast character of String is: ") print(String[-1]) ❑OUTPUT: Creating string: Welcome to NikhilArts First character of string is : W Last character of string is : s
  • 21. BINARY TREE oA tree is a hierarchical data structure that looks like the below figure – o A binary tree is a tree whose elements can have almost two children. tree ---- j <-- root / f k / a h z <-- leaves
  • 22. o Since each element in a binary tree can have only 2 children, we typically name them the left and right children. • Binary Tree node contains the following parts. ➢ Data ➢Pointer to left child ➢Pointer to the right child