SlideShare a Scribd company logo
Data Structures
Vikram Neerugatti
Sri Venkateswara College of Engineering
Content
• Lists
• Operations
• Slicing
• Methods
• Tuples
• Dictionaries
• Sets
• Comparisons
27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 2
Lists
• Lists is collection of elements.
• Elements are changeable and duplicates are allowed.
• Example: A=[1,2,3]
• Example 1
• A=[1,2,3] # only numerical in list
• print(A)
• Example 2
• B=["a",3,[2,3]] #list within the list and alphabets
• print(B)
• Elements can be list and other than numerical also
• x=[2,2,3] #duplicates
• print(x)
27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 3
Lists
• To access the elements in list- indexing is used
• List index range is 0 to n-1
• x=[2,2,3]
• print(x) #nani
• Positive indexing
• c=x[2] # 2 is the index
• print(c)
• Négative indexing
• d=x[-1]
• print(d)
27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 4
lists
• Can access the elements by range
• x=[2,2,3]
• print(x) #nani
• c=x[2]
• print(c)
• d=x[0:3]
• print(d)
• Négative range
• d=x[-3:-1]
• print(d)
27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 5
27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 6
lists
• Len()
• Append()
• Insert()
• Remove()
• Pop()
• Del
• Clear()
• Copy()
27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 7
Tuples
• A tuple is a collection which is ordered and unchangeable. In Python tuples are written
with round brackets.
• Example: a=(3,5,6,7)
• To change the values in tuple, it should be converted into list by using list function and
can be changed.
• Remaining all the operations and slicing can be done as the list.
• It has the methods shown in next slide.
27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 8
Tuples
• Example
• a=(4,5,4,4,6,7)
• print(a)
• b=list(a)
• print(b)
• print(a[2:4])
• c=a.count(4)
• print(c)
• f=a.index(6)
• print(f)
27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 9
Sets
• A set is a collection which is unordered and unindexed. In Python sets are written with curly brackets.
• You cannot access items in a set by referring to an index, since sets are unordered the items has no index.
• Add()-to add an item
• Update()-to add multiple items
• Remove() or discard() or pop()-to remove an item from sets
• Clear()-empties the sets
• del-deletes the list
27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 10
27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 11
Dictionaries
• A dictionary is a collection which is unordered, changeable and indexed.
• In Python dictionaries are written with curly brackets, and they have keys and values.
• Example
• thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
print(thisdict)
27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 12
Dictionaries
• You can access the items of a dictionary by referring to its key name, inside square brackets:
• x = thisdict["model"]
• Get()-can access the valur by using the key
• Pop()-deletes by key
• Popitem()- deletes last inserted element
• Del-removes the items
• Values(),items(),keys(), clear(), copy()
27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 13
27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 14
Comparisons
27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 15
Summary
• Lists
• Operations
• Slicing
• Methods
• Tuples
• Dictionaries
• Sets
• Comparisons
27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 16

More Related Content

PDF
Strings in Python
PPTX
How to handling strings in r
PPT
PDF
Introduction Mathematics Intelligent Systems Syllabus
PDF
Introduction Machine Learning Syllabus
PPTX
PDF
Lecture 3.6 bt
PPTX
Sequential & binary, linear search
Strings in Python
How to handling strings in r
Introduction Mathematics Intelligent Systems Syllabus
Introduction Machine Learning Syllabus
Lecture 3.6 bt
Sequential & binary, linear search

Similar to Data structures (20)

PDF
8 python data structure-1
PDF
Data Structures 01
PPTX
3 DS-Arrays.pptx 3 DS-Arrays.pptx 3 DS-Arrays.pptx
PPTX
Programming with Python_Unit-3-Notes.pptx
PPTX
Python introduction data structures lists etc
PPTX
Data Structure_Array_and_sparse matrix.pptx
PPT
data structures queue stack insert and delete time complexity
PPTX
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
PPT
java1.pptjava is programming language, having core and advanced java
PDF
Week 1 - Data Structures and Algorithms
PPTX
Introduction to Data Structures & Algorithms
PPTX
Dictionaries and Sets
PPT
Collectionsand GenericsInJavaProgramming.ppt
PDF
linked lists in data structures
PPTX
UNIT-3 python and data structure alo.pptx
PPTX
Python-List.pptx
PPTX
Python Programming for BCS Degree UNIT -4.pptx
PDF
DATA STRUCTURES USING C -ENGGDIGEST
PPT
cse403-10-Collections- iNTRODUCTION TO FRAMEWORK
PPTX
Collections lecture 35 40
8 python data structure-1
Data Structures 01
3 DS-Arrays.pptx 3 DS-Arrays.pptx 3 DS-Arrays.pptx
Programming with Python_Unit-3-Notes.pptx
Python introduction data structures lists etc
Data Structure_Array_and_sparse matrix.pptx
data structures queue stack insert and delete time complexity
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
java1.pptjava is programming language, having core and advanced java
Week 1 - Data Structures and Algorithms
Introduction to Data Structures & Algorithms
Dictionaries and Sets
Collectionsand GenericsInJavaProgramming.ppt
linked lists in data structures
UNIT-3 python and data structure alo.pptx
Python-List.pptx
Python Programming for BCS Degree UNIT -4.pptx
DATA STRUCTURES USING C -ENGGDIGEST
cse403-10-Collections- iNTRODUCTION TO FRAMEWORK
Collections lecture 35 40
Ad

More from Vikram Nandini (20)

PDF
IoT: From Copper strip to Gold Bar
PDF
Design Patterns
PDF
Linux File Trees and Commands
PDF
Introduction to Linux & Basic Commands
PDF
INTRODUCTION to OOAD
PDF
PDF
Manufacturing - II Part
PDF
Manufacturing
PDF
Business Models
PDF
Prototyping Online Components
PDF
Artificial Neural Networks
PDF
IoT-Prototyping
PDF
Design Principles for Connected Devices
PDF
Introduction to IoT
PDF
Embedded decices
PDF
Communication in the IoT
PDF
Introduction to Cyber Security
PDF
cloud computing UNIT-2.pdf
PDF
Introduction to Web Technologies
PDF
Cascading Style Sheets
IoT: From Copper strip to Gold Bar
Design Patterns
Linux File Trees and Commands
Introduction to Linux & Basic Commands
INTRODUCTION to OOAD
Manufacturing - II Part
Manufacturing
Business Models
Prototyping Online Components
Artificial Neural Networks
IoT-Prototyping
Design Principles for Connected Devices
Introduction to IoT
Embedded decices
Communication in the IoT
Introduction to Cyber Security
cloud computing UNIT-2.pdf
Introduction to Web Technologies
Cascading Style Sheets
Ad

Recently uploaded (20)

PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
PDF
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PPTX
Software Engineering and software moduleing
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PPTX
Module 8- Technological and Communication Skills.pptx
PPT
Occupational Health and Safety Management System
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
communication and presentation skills 01
PDF
22EC502-MICROCONTROLLER AND INTERFACING-8051 MICROCONTROLLER.pdf
PPTX
Fundamentals of Mechanical Engineering.pptx
PDF
distributed database system" (DDBS) is often used to refer to both the distri...
PDF
Categorization of Factors Affecting Classification Algorithms Selection
PDF
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
PDF
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
PDF
Soil Improvement Techniques Note - Rabbi
PPTX
Information Storage and Retrieval Techniques Unit III
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
Software Engineering and software moduleing
Automation-in-Manufacturing-Chapter-Introduction.pdf
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
Module 8- Technological and Communication Skills.pptx
Occupational Health and Safety Management System
R24 SURVEYING LAB MANUAL for civil enggi
communication and presentation skills 01
22EC502-MICROCONTROLLER AND INTERFACING-8051 MICROCONTROLLER.pdf
Fundamentals of Mechanical Engineering.pptx
distributed database system" (DDBS) is often used to refer to both the distri...
Categorization of Factors Affecting Classification Algorithms Selection
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
Soil Improvement Techniques Note - Rabbi
Information Storage and Retrieval Techniques Unit III
Fundamentals of safety and accident prevention -final (1).pptx

Data structures

  • 1. Data Structures Vikram Neerugatti Sri Venkateswara College of Engineering
  • 2. Content • Lists • Operations • Slicing • Methods • Tuples • Dictionaries • Sets • Comparisons 27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 2
  • 3. Lists • Lists is collection of elements. • Elements are changeable and duplicates are allowed. • Example: A=[1,2,3] • Example 1 • A=[1,2,3] # only numerical in list • print(A) • Example 2 • B=["a",3,[2,3]] #list within the list and alphabets • print(B) • Elements can be list and other than numerical also • x=[2,2,3] #duplicates • print(x) 27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 3
  • 4. Lists • To access the elements in list- indexing is used • List index range is 0 to n-1 • x=[2,2,3] • print(x) #nani • Positive indexing • c=x[2] # 2 is the index • print(c) • Négative indexing • d=x[-1] • print(d) 27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 4
  • 5. lists • Can access the elements by range • x=[2,2,3] • print(x) #nani • c=x[2] • print(c) • d=x[0:3] • print(d) • Négative range • d=x[-3:-1] • print(d) 27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 5
  • 6. 27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 6
  • 7. lists • Len() • Append() • Insert() • Remove() • Pop() • Del • Clear() • Copy() 27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 7
  • 8. Tuples • A tuple is a collection which is ordered and unchangeable. In Python tuples are written with round brackets. • Example: a=(3,5,6,7) • To change the values in tuple, it should be converted into list by using list function and can be changed. • Remaining all the operations and slicing can be done as the list. • It has the methods shown in next slide. 27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 8
  • 9. Tuples • Example • a=(4,5,4,4,6,7) • print(a) • b=list(a) • print(b) • print(a[2:4]) • c=a.count(4) • print(c) • f=a.index(6) • print(f) 27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 9
  • 10. Sets • A set is a collection which is unordered and unindexed. In Python sets are written with curly brackets. • You cannot access items in a set by referring to an index, since sets are unordered the items has no index. • Add()-to add an item • Update()-to add multiple items • Remove() or discard() or pop()-to remove an item from sets • Clear()-empties the sets • del-deletes the list 27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 10
  • 11. 27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 11
  • 12. Dictionaries • A dictionary is a collection which is unordered, changeable and indexed. • In Python dictionaries are written with curly brackets, and they have keys and values. • Example • thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964 } print(thisdict) 27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 12
  • 13. Dictionaries • You can access the items of a dictionary by referring to its key name, inside square brackets: • x = thisdict["model"] • Get()-can access the valur by using the key • Pop()-deletes by key • Popitem()- deletes last inserted element • Del-removes the items • Values(),items(),keys(), clear(), copy() 27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 13
  • 14. 27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 14
  • 15. Comparisons 27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 15
  • 16. Summary • Lists • Operations • Slicing • Methods • Tuples • Dictionaries • Sets • Comparisons 27-03-2020 Vikram Neerugatti, Assistant Professor, SVCET, CHITTOOR. 16