SlideShare a Scribd company logo
1 of 19
Python
Data Structures
DR. VAZI OKHANDIAR
WWW.NRCLC.COM
NR Computer Learning Center (NRCLC)
• Established in 2002
• Provide Computer Training
• Microsoft Partner
Hands-on classroom training
Online Training
Virtual Live Training
Private Lesson
Dr. Vazi Okhandiar
 Over 30 years of teaching experience in Computer
Science & IT courses and Microsoft Products.
 Worked for the World Bank, General Motors, HP/EDS,
Toyota, CSC, Olympus, and Mitsubishi, as well as
numerous small and medium-sized enterprises.
 Education:
 DBA, Walden University
 MBA, University of California, Irvine
 Masters in Computer Science, Illinois Institute of
Technology, Chicago
 Bachelor’s Degree in Electrical Engineering,
University of California, Irvine.
 Microsoft Certified Trainer (MCT) by Microsoft and
Certified Project Management Professional (PMP) by PMI
Data Structures in Python
A data structure is a way of organizing and storing data in memory
so that it can be used efficiently.
Four types of data structure in Python:
 List
 Tuple
 Set
 Dictionary
List
List
• General Purpose
• Most widely used data structure
• Change size as needed
• Uses square bracket “[…]”
• Allow duplicate values
Tuple
• Immutable (Can’t add or change)
• Useful for fixed data
• Faster the lists
• Sequence type
• Uses round bracket “(…)”
• Allow duplicate values
Set
• Store non-duplicate items
• immutable
• Very fast access vs Lists
• Math Set Ops
• Change size as needed
• Unordered, unchangeable
• Uses curly bracket “{…}”
• duplicate values ignored
Dictionary
• Store non-duplicate items
• Key/value pairs
• Change size as needed
• Unordered
• Duplicate values ignored
• Uses curly bracket “{…}”
Lists
 A list can be created for storing any type of data that can be stored as a variable.
 A set is written with square brackets “[ .. ]”.
 FORMAT :
variable_name = [ value1, …, value n]
Example:
myList1 = [] # Create an empty list
myList2 = [1, 2, 3]
myList3 =[1, “Hello”, 3]
myList4 = [0] *3 #[0, 0, 0]
index
 The first element of a List is index as 0 instead of 1.
 The highest element number is one less than total number of elements.
Original: Value = [0, 0, 0, 0, 0]
 Value[0] = 10
 Value[1] = 1
 Value[2] = 30
UpdatedValue = [10, 1, 30, 0, 0]
index 0 1 2 3 4
value 10 1 30 0 0
index 0 1 2 3 4
value 0 0 0 0 0
Example (Slicing)
myList = [10, “Apple”, 12, 13, 14]
print (myList[1:2]) => [‘Apple’]
print (myList[:2] => [10, ‘Apple’]
print (myList[2:]) => [12, 13, 14]
print (myList[-3:-1]) => [13, 14]
if 12 in myList:
print(myList)
else:
print("Not found") => [10, ‘Apple’, 12, 13, 14]
index 0 1 2 3 4
value 10 Apple 12 13 14
Example (Updating List)
myList = [10, “Apple”, 12, 13, 14]
myList[1:2] = [20, 30]
print (myList) => Output: [10, 20, 30, 12, 13, 14]
myList.insert (3, 40)
print(myList) => Output: [10, 20, 30, 40, 12, 13, 14]
myList.append(15)
print(myList) => Output: [10, 20, 30, 40, 12, 13, 14, 15]
del myList[2]
print (myList) => Output: [10, 20, 40, 12, 13, 14, 15]
del myList[1:4]
print (myList) => Output: [10, 13, 14, 15]
myList.clear()
print(myList) => Output: []
index 0 1 2 3 4
value 10 Apple 12 13 14
Example (Merging lists)
myList1 = [10, 20, 30]
myList2 = [40, 50, 60, 70, 80]
newList1 = myList1 + myList2
or
for index in myList2:
myList1.append(index)
or
myList1.extend(myList2)
print (myList1)
Output: [10, 20, 30, 40, 50, 60, 70, 80]
Tuple
List
• General Purpose
• Most widely used data structure
• Change size as needed
• Sequence type
• Sortable
• Uses square bracket “[…]”
• Allow duplicate values
Tuple
• Immutable (Can’t add or change)
• Useful for fixed data
• Faster than lists
• Uses round bracket “(…)”
• Allow duplicate values
Set
• Store non-duplicate items
• immutable
• Very fast access vs Lists
• Math Set Ops
• Change size as needed
• Unordered, unchangeable
• Uses curly bracket “{…}”
• duplicate values ignored
Dictionary
• Store non-duplicate items
• Key/value pairs
• Change size as needed
• Unordered
• Duplicate values ignored
• Uses curly bracket “{…}”
Examples (Tuple)
myTuple = ("Apple", 10, "Orange", "Grapes", 20.0, 10)
print(myTuple[3]) => Grapes
print(myTuple[-1]) => 10
print(myTuple[2:4]) => (‘Orange’, ‘Grapes’)
print(myTuple[:4]) => (‘Apple’, 10, ‘Orange’, ‘Grapes’)
print(myTuple[2:]) => (‘Orange’, ‘Grapes’, 20.0, 10)
print(myTuple[-4:-1]) => (‘Orange’, ‘Grapes’, 20.0)
Sets
List
• General Purpose
• Most widely used data structure
• Change size as needed
• Sequence type
• Sortable
• Uses square bracket “[…]”
• Allow duplicate values
Tuple
• Immutable (Can’t add or change)
• Useful for fixed data
• Faster the lists
• Sequence type
• Uses round bracket “(…)”
• Allow duplicate values
Set
• immutable
• Math Set Ops
• Change size as needed
• Uses curly bracket “{…}”
• duplicate values ignored
Dictionary
• Store non-duplicate items
• Key/value pairs
• Change size as needed
• Unordered
• Duplicate values ignored
• Uses curly bracket “{…}”
Example (Set)
mySet1 = {"Apple", 10, "Orange", "Grapes", 20.0}
mySet2 = {30.0, 10, "Orange", "Apple", 40}
 Print (mySet1 | mySet2) or print(mySet1.union(mySet2))
{"Apple", 40, 10, "Grapes", 20.0, “Orange”, 30.0}
 Print (mySet1 & mySet2) or print(mySet1.intersection(mySet2))
 {10, ‘Apple’, ‘Orange’}
 Print (mySet1 – mySet2) or print(mySet1.difference(mySet2))
 {‘Grapes’, 20.0}
 Print (mySet1 ^ mySet2) or print(mySet1.symmetric_difference(mySet2))
 {‘Grapes’, 20.0, 30.0, 40}
A
A
A A Union B
A interest B
A difference B
A
Dictionary
List
• General Purpose
• Most widely used data structure
• Change size as needed
• Sequence type
• Sortable
• Uses square bracket “[…]”
• Allow duplicate values
Tuple
• Immutable (Can’t add or change)
• Useful for fixed data
• Faster the lists
• Sequence type
• Uses round bracket “(…)”
• Allow duplicate values
Set
• immutable
• Very fast access vs Lists
• Math Set Ops
• Change size as needed
• Uses curly bracket “{…}”
• duplicate values ignored
Dictionary
• Store non-duplicate items
• Key: value pairs
• Mutable
• Unordered
• Uses curly bracket “{…}”
Example (Dictionary)
myFriends = {"Sandy":25, "John": 20, "Jane": 22}
print(Friends.items())  output: ('Sandy’,25), ('John', 20), ('Jane', 22)
print(Friends.keys())  output: ‘Sandy’, ‘John’, ‘Jane’
print(Friends.values())  output: 25, 20. 22
print(myFriends["Sandy“])  output: 25
myFriends["Sandy"] = 30
print (myFriends.items())  output: ('Sandy',30), ('John', 20), ('Jane', 22)
myFriends.update({"Sandy": 40})
print (myFriends.items())  output: ('Sandy’,40), ('John', 20), ('Jane', 22)
myFriends.pop("Sandy")
print (myFriends.items())  output: ('John', 20), ('Jane', 22)
myFriends.popitem()
print (myFriends.items())  output: ('Sandy', 25), ('John', 20)
del myFriends["Sandy"]
print (myFriends.items())  output: ('John', 20), ('Jane', 22)
del myFriends
print (myFriends.items())  output: Error
Sample Code
myD = {"URL": "Uniform Resource Locator", "CPU": "Central Processing Unit",
"RAM": "Random Access Memory"}
print("=>" + str(myD.keys()))
print("=>"+ str(myD.values()))
print("=>" + str(myD.items()))
print(myD["URL"])
del myD["CPU"]
print("Size: " + str(len(myD)))
myKeys = list(myD.keys())
myValues = list(myD.values())
for J in range(len(myD)):
print(str(J +1) + ". "+ myKeys[ J ] + ": " + (myValues[ J ]))
OUTPUT:
 dict_keys(['URL', 'CPU', 'RAM'])
 dict_values(['Uniform Resource Locator',
'Central Processing Unit', 'Random
Access Memory'])
 dict_items([('URL', 'Uniform Resource
Locator'), ('CPU', 'Central Processing
Unit'), ('RAM', 'Random Access
Memory')])
 Uniform Resource Locator
 Size: 2
 1. URL: Uniform Resource Locator
 2. RAM: Random Access Memory
Data Structure
List
• mutable
• Uses square bracket “[value, …]”
• General Purpose
• Most widely used data structure
• Allow duplicate values
Tuple
• Immutable
• Uses round bracket “(value, …)”
• Useful for fixed data
• Allow duplicate values
Sets
• Immutable
• Uses curly bracket “{value, …}”
• Math Set Ops
• duplicate values ignored
Dictionary
• Mutable
• Uses curly bracket “{key: value, …}”
• Key/value pairs
• Non-duplicate keys
• Unordered
Free Online Python IDE
https://replit.com
Free Exercise
https://www.w3resource.com/python-exercises/
Instructor-Led and Self-Paced Online Courses
https://ed2go.com/nrclc
--------- * ----------
Vazi Okhandiar
NR computer Learning Center
www.nrclc.com

More Related Content

What's hot

Etiquetas html
Etiquetas htmlEtiquetas html
Etiquetas htmldanneszm
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaEdureka!
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/jsKnoldus Inc.
 
Introduction to JSX
Introduction to JSXIntroduction to JSX
Introduction to JSXMicah Wood
 
Learn 90% of Python in 90 Minutes
Learn 90% of Python in 90 MinutesLearn 90% of Python in 90 Minutes
Learn 90% of Python in 90 MinutesMatt Harrison
 
Intro to Jinja2 Templates - San Francisco Flask Meetup
Intro to Jinja2 Templates - San Francisco Flask MeetupIntro to Jinja2 Templates - San Francisco Flask Meetup
Intro to Jinja2 Templates - San Francisco Flask MeetupAlan Hamlett
 
ES6 PPT FOR 2016
ES6 PPT FOR 2016ES6 PPT FOR 2016
ES6 PPT FOR 2016Manoj Kumar
 
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...Edureka!
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and DjangoMichael Pirnat
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python amiable_indian
 
Introduction to Bootstrap: Design for Developers
Introduction to Bootstrap: Design for DevelopersIntroduction to Bootstrap: Design for Developers
Introduction to Bootstrap: Design for DevelopersMelvin John
 
React redux-tutoriel-1
React redux-tutoriel-1React redux-tutoriel-1
React redux-tutoriel-1Sem Koto
 
Advanced Use of jinja2 for Templates
Advanced Use of jinja2 for TemplatesAdvanced Use of jinja2 for Templates
Advanced Use of jinja2 for TemplatesKeith Resar
 
4 internet programming
4 internet programming4 internet programming
4 internet programmingsoner_kavlak
 

What's hot (20)

Etiquetas html
Etiquetas htmlEtiquetas html
Etiquetas html
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
 
Programação Web com HTML e CSS
Programação Web com HTML e CSSProgramação Web com HTML e CSS
Programação Web com HTML e CSS
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
 
Introduction to JSX
Introduction to JSXIntroduction to JSX
Introduction to JSX
 
Learn 90% of Python in 90 Minutes
Learn 90% of Python in 90 MinutesLearn 90% of Python in 90 Minutes
Learn 90% of Python in 90 Minutes
 
Intro to Jinja2 Templates - San Francisco Flask Meetup
Intro to Jinja2 Templates - San Francisco Flask MeetupIntro to Jinja2 Templates - San Francisco Flask Meetup
Intro to Jinja2 Templates - San Francisco Flask Meetup
 
ES6 PPT FOR 2016
ES6 PPT FOR 2016ES6 PPT FOR 2016
ES6 PPT FOR 2016
 
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and Django
 
Node.js e Express
Node.js e ExpressNode.js e Express
Node.js e Express
 
Oops in PHP
Oops in PHPOops in PHP
Oops in PHP
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python
 
Javascript essentials
Javascript essentialsJavascript essentials
Javascript essentials
 
Php Unit 1
Php Unit 1Php Unit 1
Php Unit 1
 
Introduction to Bootstrap: Design for Developers
Introduction to Bootstrap: Design for DevelopersIntroduction to Bootstrap: Design for Developers
Introduction to Bootstrap: Design for Developers
 
React redux-tutoriel-1
React redux-tutoriel-1React redux-tutoriel-1
React redux-tutoriel-1
 
Advanced Use of jinja2 for Templates
Advanced Use of jinja2 for TemplatesAdvanced Use of jinja2 for Templates
Advanced Use of jinja2 for Templates
 
4 internet programming
4 internet programming4 internet programming
4 internet programming
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 

Similar to Python - Data Structures

Pa1 session 3_slides
Pa1 session 3_slidesPa1 session 3_slides
Pa1 session 3_slidesaiclub_slides
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionarySoba Arjun
 
Python PCEP Tuples and Dictionaries
Python PCEP Tuples and DictionariesPython PCEP Tuples and Dictionaries
Python PCEP Tuples and DictionariesIHTMINSTITUTE
 
Python PCEP Tuples and Dictionaries
Python PCEP Tuples and DictionariesPython PCEP Tuples and Dictionaries
Python PCEP Tuples and DictionariesIHTMINSTITUTE
 
Dynamic languages, for software craftmanship group
Dynamic languages, for software craftmanship groupDynamic languages, for software craftmanship group
Dynamic languages, for software craftmanship groupReuven Lerner
 
Python Programming: Lists, Modules, Exceptions
Python Programming: Lists, Modules, ExceptionsPython Programming: Lists, Modules, Exceptions
Python Programming: Lists, Modules, ExceptionsSreedhar Chowdam
 
Introduction to Search Systems - ScaleConf Colombia 2017
Introduction to Search Systems - ScaleConf Colombia 2017Introduction to Search Systems - ScaleConf Colombia 2017
Introduction to Search Systems - ScaleConf Colombia 2017Toria Gibbs
 
GreenDao Introduction
GreenDao IntroductionGreenDao Introduction
GreenDao IntroductionBooch Lin
 
Learn python - for beginners - part-2
Learn python - for beginners - part-2Learn python - for beginners - part-2
Learn python - for beginners - part-2RajKumar Rampelli
 
Python for High School Programmers
Python for High School ProgrammersPython for High School Programmers
Python for High School ProgrammersSiva Arunachalam
 
Big Data LDN 2017: From Zero to AI in 30 Minutes
Big Data LDN 2017: From Zero to AI in 30 MinutesBig Data LDN 2017: From Zero to AI in 30 Minutes
Big Data LDN 2017: From Zero to AI in 30 MinutesMatt Stubbs
 
Types Working for You, Not Against You
Types Working for You, Not Against YouTypes Working for You, Not Against You
Types Working for You, Not Against YouC4Media
 
Introduction to R
Introduction to RIntroduction to R
Introduction to Rvpletap
 
list and control statement.pptx
list and control statement.pptxlist and control statement.pptx
list and control statement.pptxssuser8f0410
 

Similar to Python - Data Structures (20)

8 python data structure-1
8 python data structure-18 python data structure-1
8 python data structure-1
 
Pa1 session 3_slides
Pa1 session 3_slidesPa1 session 3_slides
Pa1 session 3_slides
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, Dictionary
 
Python PCEP Tuples and Dictionaries
Python PCEP Tuples and DictionariesPython PCEP Tuples and Dictionaries
Python PCEP Tuples and Dictionaries
 
Python PCEP Tuples and Dictionaries
Python PCEP Tuples and DictionariesPython PCEP Tuples and Dictionaries
Python PCEP Tuples and Dictionaries
 
Ggplot2 v3
Ggplot2 v3Ggplot2 v3
Ggplot2 v3
 
Dynamic languages, for software craftmanship group
Dynamic languages, for software craftmanship groupDynamic languages, for software craftmanship group
Dynamic languages, for software craftmanship group
 
Python Programming: Lists, Modules, Exceptions
Python Programming: Lists, Modules, ExceptionsPython Programming: Lists, Modules, Exceptions
Python Programming: Lists, Modules, Exceptions
 
Introduction to Search Systems - ScaleConf Colombia 2017
Introduction to Search Systems - ScaleConf Colombia 2017Introduction to Search Systems - ScaleConf Colombia 2017
Introduction to Search Systems - ScaleConf Colombia 2017
 
GreenDao Introduction
GreenDao IntroductionGreenDao Introduction
GreenDao Introduction
 
Learn python - for beginners - part-2
Learn python - for beginners - part-2Learn python - for beginners - part-2
Learn python - for beginners - part-2
 
Python for High School Programmers
Python for High School ProgrammersPython for High School Programmers
Python for High School Programmers
 
Office
OfficeOffice
Office
 
Begin with Python
Begin with PythonBegin with Python
Begin with Python
 
Big Data LDN 2017: From Zero to AI in 30 Minutes
Big Data LDN 2017: From Zero to AI in 30 MinutesBig Data LDN 2017: From Zero to AI in 30 Minutes
Big Data LDN 2017: From Zero to AI in 30 Minutes
 
R learning by examples
R learning by examplesR learning by examples
R learning by examples
 
Types Working for You, Not Against You
Types Working for You, Not Against YouTypes Working for You, Not Against You
Types Working for You, Not Against You
 
Introduction to R
Introduction to RIntroduction to R
Introduction to R
 
list and control statement.pptx
list and control statement.pptxlist and control statement.pptx
list and control statement.pptx
 
Python slide
Python slidePython slide
Python slide
 

More from NR Computer Learning Center

App Development with Apple Swift Certification at Certiport Centers
App Development with Apple Swift Certification at Certiport CentersApp Development with Apple Swift Certification at Certiport Centers
App Development with Apple Swift Certification at Certiport CentersNR Computer Learning Center
 
Building a Dashboard in an hour with Power Pivot and Power BI
Building a Dashboard in an hour with Power Pivot and Power BIBuilding a Dashboard in an hour with Power Pivot and Power BI
Building a Dashboard in an hour with Power Pivot and Power BINR Computer Learning Center
 
Introduction to the basic mathematical concept with Python Turtle.
Introduction to the basic mathematical concept with Python Turtle.Introduction to the basic mathematical concept with Python Turtle.
Introduction to the basic mathematical concept with Python Turtle.NR Computer Learning Center
 
Stem presentation - Pathways to Technology Oriented Careers
Stem presentation - Pathways to Technology Oriented CareersStem presentation - Pathways to Technology Oriented Careers
Stem presentation - Pathways to Technology Oriented CareersNR Computer Learning Center
 
Building a Dashboard in an Hour using Microsoft PowerPivot & Power BI
Building a Dashboard in an Hour using Microsoft PowerPivot & Power BIBuilding a Dashboard in an Hour using Microsoft PowerPivot & Power BI
Building a Dashboard in an Hour using Microsoft PowerPivot & Power BINR Computer Learning Center
 
Microsoft Office Specialist (MOS) Excel 2013 certification pathway
Microsoft Office Specialist (MOS) Excel 2013 certification pathwayMicrosoft Office Specialist (MOS) Excel 2013 certification pathway
Microsoft Office Specialist (MOS) Excel 2013 certification pathwayNR Computer Learning Center
 

More from NR Computer Learning Center (20)

Power BI Desktop Overview
Power BI Desktop Overview Power BI Desktop Overview
Power BI Desktop Overview
 
Building Dashboard with Excel
Building Dashboard with ExcelBuilding Dashboard with Excel
Building Dashboard with Excel
 
Introduction to Data Analytics
Introduction to Data AnalyticsIntroduction to Data Analytics
Introduction to Data Analytics
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
Office 2019 tips & tricks
Office 2019 tips & tricksOffice 2019 tips & tricks
Office 2019 tips & tricks
 
App Development with Apple Swift Certification at Certiport Centers
App Development with Apple Swift Certification at Certiport CentersApp Development with Apple Swift Certification at Certiport Centers
App Development with Apple Swift Certification at Certiport Centers
 
Project management fundamentals
Project management fundamentalsProject management fundamentals
Project management fundamentals
 
National College Testing Association (NCTA)
National College Testing Association (NCTA)National College Testing Association (NCTA)
National College Testing Association (NCTA)
 
National College Testing Association (NCTA)
National College Testing Association (NCTA)National College Testing Association (NCTA)
National College Testing Association (NCTA)
 
Building a Dashboard in an hour with Power Pivot and Power BI
Building a Dashboard in an hour with Power Pivot and Power BIBuilding a Dashboard in an hour with Power Pivot and Power BI
Building a Dashboard in an hour with Power Pivot and Power BI
 
Introduction to the basic mathematical concept with Python Turtle.
Introduction to the basic mathematical concept with Python Turtle.Introduction to the basic mathematical concept with Python Turtle.
Introduction to the basic mathematical concept with Python Turtle.
 
Stem presentation - Pathways to Technology Oriented Careers
Stem presentation - Pathways to Technology Oriented CareersStem presentation - Pathways to Technology Oriented Careers
Stem presentation - Pathways to Technology Oriented Careers
 
MTA 98 364 - database fundamentals
MTA 98 364 - database fundamentalsMTA 98 364 - database fundamentals
MTA 98 364 - database fundamentals
 
MTA 361 software development fundamentals
MTA 361   software development fundamentalsMTA 361   software development fundamentals
MTA 361 software development fundamentals
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
 
Executive dashboard for small business
Executive dashboard for small businessExecutive dashboard for small business
Executive dashboard for small business
 
Building a Dashboard in an Hour using Microsoft PowerPivot & Power BI
Building a Dashboard in an Hour using Microsoft PowerPivot & Power BIBuilding a Dashboard in an Hour using Microsoft PowerPivot & Power BI
Building a Dashboard in an Hour using Microsoft PowerPivot & Power BI
 
Arduino for teens
Arduino for teensArduino for teens
Arduino for teens
 
Microsoft Office Specialist (MOS) Excel 2013 certification pathway
Microsoft Office Specialist (MOS) Excel 2013 certification pathwayMicrosoft Office Specialist (MOS) Excel 2013 certification pathway
Microsoft Office Specialist (MOS) Excel 2013 certification pathway
 

Recently uploaded

9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改atducpo
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfgstagge
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样vhwb25kk
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024thyngster
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一fhwihughh
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...Florian Roscheck
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDRafezzaman
 

Recently uploaded (20)

9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
E-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptxE-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptx
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdf
 
Decoding Loan Approval: Predictive Modeling in Action
Decoding Loan Approval: Predictive Modeling in ActionDecoding Loan Approval: Predictive Modeling in Action
Decoding Loan Approval: Predictive Modeling in Action
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
 

Python - Data Structures

  • 1. Python Data Structures DR. VAZI OKHANDIAR WWW.NRCLC.COM
  • 2. NR Computer Learning Center (NRCLC) • Established in 2002 • Provide Computer Training • Microsoft Partner Hands-on classroom training Online Training Virtual Live Training Private Lesson
  • 3. Dr. Vazi Okhandiar  Over 30 years of teaching experience in Computer Science & IT courses and Microsoft Products.  Worked for the World Bank, General Motors, HP/EDS, Toyota, CSC, Olympus, and Mitsubishi, as well as numerous small and medium-sized enterprises.  Education:  DBA, Walden University  MBA, University of California, Irvine  Masters in Computer Science, Illinois Institute of Technology, Chicago  Bachelor’s Degree in Electrical Engineering, University of California, Irvine.  Microsoft Certified Trainer (MCT) by Microsoft and Certified Project Management Professional (PMP) by PMI
  • 4. Data Structures in Python A data structure is a way of organizing and storing data in memory so that it can be used efficiently. Four types of data structure in Python:  List  Tuple  Set  Dictionary
  • 5. List List • General Purpose • Most widely used data structure • Change size as needed • Uses square bracket “[…]” • Allow duplicate values Tuple • Immutable (Can’t add or change) • Useful for fixed data • Faster the lists • Sequence type • Uses round bracket “(…)” • Allow duplicate values Set • Store non-duplicate items • immutable • Very fast access vs Lists • Math Set Ops • Change size as needed • Unordered, unchangeable • Uses curly bracket “{…}” • duplicate values ignored Dictionary • Store non-duplicate items • Key/value pairs • Change size as needed • Unordered • Duplicate values ignored • Uses curly bracket “{…}”
  • 6. Lists  A list can be created for storing any type of data that can be stored as a variable.  A set is written with square brackets “[ .. ]”.  FORMAT : variable_name = [ value1, …, value n] Example: myList1 = [] # Create an empty list myList2 = [1, 2, 3] myList3 =[1, “Hello”, 3] myList4 = [0] *3 #[0, 0, 0]
  • 7. index  The first element of a List is index as 0 instead of 1.  The highest element number is one less than total number of elements. Original: Value = [0, 0, 0, 0, 0]  Value[0] = 10  Value[1] = 1  Value[2] = 30 UpdatedValue = [10, 1, 30, 0, 0] index 0 1 2 3 4 value 10 1 30 0 0 index 0 1 2 3 4 value 0 0 0 0 0
  • 8. Example (Slicing) myList = [10, “Apple”, 12, 13, 14] print (myList[1:2]) => [‘Apple’] print (myList[:2] => [10, ‘Apple’] print (myList[2:]) => [12, 13, 14] print (myList[-3:-1]) => [13, 14] if 12 in myList: print(myList) else: print("Not found") => [10, ‘Apple’, 12, 13, 14] index 0 1 2 3 4 value 10 Apple 12 13 14
  • 9. Example (Updating List) myList = [10, “Apple”, 12, 13, 14] myList[1:2] = [20, 30] print (myList) => Output: [10, 20, 30, 12, 13, 14] myList.insert (3, 40) print(myList) => Output: [10, 20, 30, 40, 12, 13, 14] myList.append(15) print(myList) => Output: [10, 20, 30, 40, 12, 13, 14, 15] del myList[2] print (myList) => Output: [10, 20, 40, 12, 13, 14, 15] del myList[1:4] print (myList) => Output: [10, 13, 14, 15] myList.clear() print(myList) => Output: [] index 0 1 2 3 4 value 10 Apple 12 13 14
  • 10. Example (Merging lists) myList1 = [10, 20, 30] myList2 = [40, 50, 60, 70, 80] newList1 = myList1 + myList2 or for index in myList2: myList1.append(index) or myList1.extend(myList2) print (myList1) Output: [10, 20, 30, 40, 50, 60, 70, 80]
  • 11. Tuple List • General Purpose • Most widely used data structure • Change size as needed • Sequence type • Sortable • Uses square bracket “[…]” • Allow duplicate values Tuple • Immutable (Can’t add or change) • Useful for fixed data • Faster than lists • Uses round bracket “(…)” • Allow duplicate values Set • Store non-duplicate items • immutable • Very fast access vs Lists • Math Set Ops • Change size as needed • Unordered, unchangeable • Uses curly bracket “{…}” • duplicate values ignored Dictionary • Store non-duplicate items • Key/value pairs • Change size as needed • Unordered • Duplicate values ignored • Uses curly bracket “{…}”
  • 12. Examples (Tuple) myTuple = ("Apple", 10, "Orange", "Grapes", 20.0, 10) print(myTuple[3]) => Grapes print(myTuple[-1]) => 10 print(myTuple[2:4]) => (‘Orange’, ‘Grapes’) print(myTuple[:4]) => (‘Apple’, 10, ‘Orange’, ‘Grapes’) print(myTuple[2:]) => (‘Orange’, ‘Grapes’, 20.0, 10) print(myTuple[-4:-1]) => (‘Orange’, ‘Grapes’, 20.0)
  • 13. Sets List • General Purpose • Most widely used data structure • Change size as needed • Sequence type • Sortable • Uses square bracket “[…]” • Allow duplicate values Tuple • Immutable (Can’t add or change) • Useful for fixed data • Faster the lists • Sequence type • Uses round bracket “(…)” • Allow duplicate values Set • immutable • Math Set Ops • Change size as needed • Uses curly bracket “{…}” • duplicate values ignored Dictionary • Store non-duplicate items • Key/value pairs • Change size as needed • Unordered • Duplicate values ignored • Uses curly bracket “{…}”
  • 14. Example (Set) mySet1 = {"Apple", 10, "Orange", "Grapes", 20.0} mySet2 = {30.0, 10, "Orange", "Apple", 40}  Print (mySet1 | mySet2) or print(mySet1.union(mySet2)) {"Apple", 40, 10, "Grapes", 20.0, “Orange”, 30.0}  Print (mySet1 & mySet2) or print(mySet1.intersection(mySet2))  {10, ‘Apple’, ‘Orange’}  Print (mySet1 – mySet2) or print(mySet1.difference(mySet2))  {‘Grapes’, 20.0}  Print (mySet1 ^ mySet2) or print(mySet1.symmetric_difference(mySet2))  {‘Grapes’, 20.0, 30.0, 40} A A A A Union B A interest B A difference B A
  • 15. Dictionary List • General Purpose • Most widely used data structure • Change size as needed • Sequence type • Sortable • Uses square bracket “[…]” • Allow duplicate values Tuple • Immutable (Can’t add or change) • Useful for fixed data • Faster the lists • Sequence type • Uses round bracket “(…)” • Allow duplicate values Set • immutable • Very fast access vs Lists • Math Set Ops • Change size as needed • Uses curly bracket “{…}” • duplicate values ignored Dictionary • Store non-duplicate items • Key: value pairs • Mutable • Unordered • Uses curly bracket “{…}”
  • 16. Example (Dictionary) myFriends = {"Sandy":25, "John": 20, "Jane": 22} print(Friends.items())  output: ('Sandy’,25), ('John', 20), ('Jane', 22) print(Friends.keys())  output: ‘Sandy’, ‘John’, ‘Jane’ print(Friends.values())  output: 25, 20. 22 print(myFriends["Sandy“])  output: 25 myFriends["Sandy"] = 30 print (myFriends.items())  output: ('Sandy',30), ('John', 20), ('Jane', 22) myFriends.update({"Sandy": 40}) print (myFriends.items())  output: ('Sandy’,40), ('John', 20), ('Jane', 22) myFriends.pop("Sandy") print (myFriends.items())  output: ('John', 20), ('Jane', 22) myFriends.popitem() print (myFriends.items())  output: ('Sandy', 25), ('John', 20) del myFriends["Sandy"] print (myFriends.items())  output: ('John', 20), ('Jane', 22) del myFriends print (myFriends.items())  output: Error
  • 17. Sample Code myD = {"URL": "Uniform Resource Locator", "CPU": "Central Processing Unit", "RAM": "Random Access Memory"} print("=>" + str(myD.keys())) print("=>"+ str(myD.values())) print("=>" + str(myD.items())) print(myD["URL"]) del myD["CPU"] print("Size: " + str(len(myD))) myKeys = list(myD.keys()) myValues = list(myD.values()) for J in range(len(myD)): print(str(J +1) + ". "+ myKeys[ J ] + ": " + (myValues[ J ])) OUTPUT:  dict_keys(['URL', 'CPU', 'RAM'])  dict_values(['Uniform Resource Locator', 'Central Processing Unit', 'Random Access Memory'])  dict_items([('URL', 'Uniform Resource Locator'), ('CPU', 'Central Processing Unit'), ('RAM', 'Random Access Memory')])  Uniform Resource Locator  Size: 2  1. URL: Uniform Resource Locator  2. RAM: Random Access Memory
  • 18. Data Structure List • mutable • Uses square bracket “[value, …]” • General Purpose • Most widely used data structure • Allow duplicate values Tuple • Immutable • Uses round bracket “(value, …)” • Useful for fixed data • Allow duplicate values Sets • Immutable • Uses curly bracket “{value, …}” • Math Set Ops • duplicate values ignored Dictionary • Mutable • Uses curly bracket “{key: value, …}” • Key/value pairs • Non-duplicate keys • Unordered
  • 19. Free Online Python IDE https://replit.com Free Exercise https://www.w3resource.com/python-exercises/ Instructor-Led and Self-Paced Online Courses https://ed2go.com/nrclc --------- * ---------- Vazi Okhandiar NR computer Learning Center www.nrclc.com