SlideShare a Scribd company logo
1 of 20
Download to read offline
Sequence Data Types
by
Jyostna Devi Bodapati
Python Programming Specialization
Python Programming – Data Structures
Python Data Types
Data Types
Scalar Data
int
float
complex
boolean
Sequence Data
List
Tuple
String
Mapping Type
Dictionary
Set Type
Set
Frozen Set
Python Programming Specialization
Python Programming – Data Structures
Sequence Types
Python Programming Specialization
Python Programming – Data Structures
Sequence Data Types
Sequence is the ordered collection of elements
Allows to store multiple values in an organized and efficient manner
Sequence
String List Tuple
Python Programming Specialization
Python Programming – Data Structures
Sequence Data Type: str
Python Programming Specialization
Python Programming – Data Structures
Sequence Types: str
• A string is a collection of one or more characters
• Python strings can be enclosed either in single, double or triple quotes
• Python Strings belongs to str class
Python Programming Specialization
Python Programming – Data Structures
Creation of Strings
>>>S1 = ‘Python’
>>>S2 = “Python”
>>>S3 = ‘’’Python’’’
>>>S4 = ‘’’Python
Programming
Specialization’’’
Python Programming Specialization
Python Programming – Data Structures
Accessing String Elements
• Let S1 = “HELLO WORLD”
• How do we access the contents of the string?
• String elements can be accessed by passing an index with the name of the
string
• String name [ index ]
Python Programming Specialization
Python Programming – Data Structures
String Indexing
• Indexing must be an integer
• Both negative and positive indexing are valid
• Ex: S1 = “HELLO WORLD”
Python Programming Specialization
Python Programming – Data Structures
String Indexing
• Integer indexing can be used to access string elements
• Both negative and positive indexing are valid
• Ex: S1 = “HELLO WORLD”
Python Programming Specialization
Python Programming – Data Structures
String Indexing
• Integer indexing can be used to access string elements
• Both negative and positive indexing are valid
• Ex: S1 = “HELLO WORLD”
Python Programming Specialization
Python Programming – Data Structures
Accessing String Elements
• Ex: S1 = “HELLO WORLD”
>>> S1 [ 0 ]
>>> S1 [ 4 ]
>>> S1 [ -2 ]
>>> S1 [ 2: 7 ]
Python Programming Specialization
Python Programming – Data Structures
Accessing String Elements
• Ex: S1 = “HELLO WORLD”
>>> S1 [ 0 ]
>>> S1 [ 4 ]
>>> S1 [ -2 ]
>>> S1 [ 2 : 7 ]
>>> S1 [ 2 : 10 : 2 ]
#returns H
#returns O
#returns L
#returns LLO W
#returns LOWR
Python Programming Specialization
Python Programming – Data Structures
Sequence Data Type: list
Python Programming Specialization
Python Programming – Data Structures
Sequence Types: list
• Ordered collections of objects​ of same or different types
• Lists are Mutable​
• Examples:
• >>>L3 = [10, 20, 30, 40]
• >>> L4 = [‘Ram', 786 , 2.23, ‘Raj', 70.2]
Python Programming Specialization
Python Programming – Data Structures
Sequence Types: list
• L1 = [10, 20, 30, 40, 50, 60, 70]
• Access the entire list → use is its name.​
• >>> Print ( L1 )​
• Access a single item → use index operator [ ] ​
• >>> L1 [ 0 ] ​
• Access part of a list → use slicing operator [ : : ]​
• >>> L1 [ 4 : 8 : 2 ]
Python Programming Specialization
Python Programming – Data Structures
Sequence Data Type: tuple
Python Programming Specialization
Python Programming – Data Structures
Sequence Types: tuple
• Ordered collections of objects​ of same or different types
• Tuples are Immutable
• Examples:
• >>> T1 = ( 9, 2, 13, 24 )
• >>> T2 = ( ‘Ram', 786 , 2.23, ‘Raj', 70.2 )
Python Programming Specialization
Python Programming – Data Structures
Access tuple Elements
• T1 = ( 10, 20, 30, 40, 50, 60, 70 )
• Access the entire tuple → use is its name.​
• >>> Print ( T1 )​
• Access a single item → use index operator [ ] ​
• >>> T1 [ 0 ] ​
• Access part of a tuple → use slicing operator [ : : ]​
• >>> T1 [ 2 : 6 : 2 ]
Python Sequence Data types in Brief

More Related Content

What's hot

Introduction to Recursion (Python)
Introduction to Recursion (Python)Introduction to Recursion (Python)
Introduction to Recursion (Python)Thai Pangsakulyanont
 
Python Generators
Python GeneratorsPython Generators
Python GeneratorsAkshar Raaj
 
Command line-arguments-in-java-tutorial
Command line-arguments-in-java-tutorialCommand line-arguments-in-java-tutorial
Command line-arguments-in-java-tutorialKuntal Bhowmick
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statementnarmadhakin
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slidesrfojdar
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in PythonDevashish Kumar
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in pythoneShikshak
 
Iterarators and generators in python
Iterarators and generators in pythonIterarators and generators in python
Iterarators and generators in pythonSarfaraz Ghanta
 
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...Edureka!
 
String and string buffer
String and string bufferString and string buffer
String and string bufferkamal kotecha
 
Unit 4 python -list methods
Unit 4   python -list methodsUnit 4   python -list methods
Unit 4 python -list methodsnarmadhakin
 
Command line arguments
Command line argumentsCommand line arguments
Command line argumentsAshok Raj
 
Java data types, variables and jvm
Java data types, variables and jvm Java data types, variables and jvm
Java data types, variables and jvm Madishetty Prathibha
 

What's hot (20)

Data types in python
Data types in pythonData types in python
Data types in python
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Introduction to Recursion (Python)
Introduction to Recursion (Python)Introduction to Recursion (Python)
Introduction to Recursion (Python)
 
Python Generators
Python GeneratorsPython Generators
Python Generators
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
 
Command line-arguments-in-java-tutorial
Command line-arguments-in-java-tutorialCommand line-arguments-in-java-tutorial
Command line-arguments-in-java-tutorial
 
Python strings
Python stringsPython strings
Python strings
 
Nested loops
Nested loopsNested loops
Nested loops
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slides
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Iterarators and generators in python
Iterarators and generators in pythonIterarators and generators in python
Iterarators and generators in python
 
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
 
Operators in java
Operators in javaOperators in java
Operators in java
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
 
Unit 4 python -list methods
Unit 4   python -list methodsUnit 4   python -list methods
Unit 4 python -list methods
 
Command line arguments
Command line argumentsCommand line arguments
Command line arguments
 
Java data types, variables and jvm
Java data types, variables and jvm Java data types, variables and jvm
Java data types, variables and jvm
 

Similar to Python Sequence Data types in Brief

Programming in Python
Programming in Python Programming in Python
Programming in Python Tiji Thomas
 
INTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptxINTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptxNimrahafzal1
 
Presentation on python data type
Presentation on python data typePresentation on python data type
Presentation on python data typeswati kushwaha
 
PPT on Python - illustrating Python for BBA, B.Tech
PPT on Python - illustrating Python for BBA, B.TechPPT on Python - illustrating Python for BBA, B.Tech
PPT on Python - illustrating Python for BBA, B.Techssuser2678ab
 
Python bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of NairobiPython bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of Nairobikrmboya
 
Python programming
Python programmingPython programming
Python programmingsirikeshava
 
Stacks in Python will be made using lists.pdf
Stacks in Python will be made using lists.pdfStacks in Python will be made using lists.pdf
Stacks in Python will be made using lists.pdfDeeptiMalhotra19
 
web programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Malothweb programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh MalothBhavsingh Maloth
 
examples of iterators in python for university level
examples of iterators in python for university levelexamples of iterators in python for university level
examples of iterators in python for university levelshamraiztasawar11
 
Processing data with Python, using standard library modules you (probably) ne...
Processing data with Python, using standard library modules you (probably) ne...Processing data with Python, using standard library modules you (probably) ne...
Processing data with Python, using standard library modules you (probably) ne...gjcross
 
1. python programming
1. python programming1. python programming
1. python programmingsreeLekha51
 
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptxsangeeta borde
 
Python programming
Python programmingPython programming
Python programmingsaroja20
 

Similar to Python Sequence Data types in Brief (20)

intro to python.pptx
intro to python.pptxintro to python.pptx
intro to python.pptx
 
Programming in Python
Programming in Python Programming in Python
Programming in Python
 
Python programming
Python programmingPython programming
Python programming
 
Python_IoT.pptx
Python_IoT.pptxPython_IoT.pptx
Python_IoT.pptx
 
Python-Basics.pptx
Python-Basics.pptxPython-Basics.pptx
Python-Basics.pptx
 
INTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptxINTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptx
 
AI_2nd Lab.pptx
AI_2nd Lab.pptxAI_2nd Lab.pptx
AI_2nd Lab.pptx
 
Presentation on python data type
Presentation on python data typePresentation on python data type
Presentation on python data type
 
PPT on Python - illustrating Python for BBA, B.Tech
PPT on Python - illustrating Python for BBA, B.TechPPT on Python - illustrating Python for BBA, B.Tech
PPT on Python - illustrating Python for BBA, B.Tech
 
Python bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of NairobiPython bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of Nairobi
 
Python ppt
Python pptPython ppt
Python ppt
 
Python programming
Python programmingPython programming
Python programming
 
Stacks in Python will be made using lists.pdf
Stacks in Python will be made using lists.pdfStacks in Python will be made using lists.pdf
Stacks in Python will be made using lists.pdf
 
web programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Malothweb programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Maloth
 
examples of iterators in python for university level
examples of iterators in python for university levelexamples of iterators in python for university level
examples of iterators in python for university level
 
Processing data with Python, using standard library modules you (probably) ne...
Processing data with Python, using standard library modules you (probably) ne...Processing data with Python, using standard library modules you (probably) ne...
Processing data with Python, using standard library modules you (probably) ne...
 
1. python programming
1. python programming1. python programming
1. python programming
 
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
 
Python programming
Python programmingPython programming
Python programming
 
Python
PythonPython
Python
 

Recently uploaded

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 

Recently uploaded (20)

Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 

Python Sequence Data types in Brief

  • 2. Python Programming Specialization Python Programming – Data Structures Python Data Types Data Types Scalar Data int float complex boolean Sequence Data List Tuple String Mapping Type Dictionary Set Type Set Frozen Set
  • 3. Python Programming Specialization Python Programming – Data Structures Sequence Types
  • 4. Python Programming Specialization Python Programming – Data Structures Sequence Data Types Sequence is the ordered collection of elements Allows to store multiple values in an organized and efficient manner Sequence String List Tuple
  • 5. Python Programming Specialization Python Programming – Data Structures Sequence Data Type: str
  • 6. Python Programming Specialization Python Programming – Data Structures Sequence Types: str • A string is a collection of one or more characters • Python strings can be enclosed either in single, double or triple quotes • Python Strings belongs to str class
  • 7. Python Programming Specialization Python Programming – Data Structures Creation of Strings >>>S1 = ‘Python’ >>>S2 = “Python” >>>S3 = ‘’’Python’’’ >>>S4 = ‘’’Python Programming Specialization’’’
  • 8. Python Programming Specialization Python Programming – Data Structures Accessing String Elements • Let S1 = “HELLO WORLD” • How do we access the contents of the string? • String elements can be accessed by passing an index with the name of the string • String name [ index ]
  • 9. Python Programming Specialization Python Programming – Data Structures String Indexing • Indexing must be an integer • Both negative and positive indexing are valid • Ex: S1 = “HELLO WORLD”
  • 10. Python Programming Specialization Python Programming – Data Structures String Indexing • Integer indexing can be used to access string elements • Both negative and positive indexing are valid • Ex: S1 = “HELLO WORLD”
  • 11. Python Programming Specialization Python Programming – Data Structures String Indexing • Integer indexing can be used to access string elements • Both negative and positive indexing are valid • Ex: S1 = “HELLO WORLD”
  • 12. Python Programming Specialization Python Programming – Data Structures Accessing String Elements • Ex: S1 = “HELLO WORLD” >>> S1 [ 0 ] >>> S1 [ 4 ] >>> S1 [ -2 ] >>> S1 [ 2: 7 ]
  • 13. Python Programming Specialization Python Programming – Data Structures Accessing String Elements • Ex: S1 = “HELLO WORLD” >>> S1 [ 0 ] >>> S1 [ 4 ] >>> S1 [ -2 ] >>> S1 [ 2 : 7 ] >>> S1 [ 2 : 10 : 2 ] #returns H #returns O #returns L #returns LLO W #returns LOWR
  • 14. Python Programming Specialization Python Programming – Data Structures Sequence Data Type: list
  • 15. Python Programming Specialization Python Programming – Data Structures Sequence Types: list • Ordered collections of objects​ of same or different types • Lists are Mutable​ • Examples: • >>>L3 = [10, 20, 30, 40] • >>> L4 = [‘Ram', 786 , 2.23, ‘Raj', 70.2]
  • 16. Python Programming Specialization Python Programming – Data Structures Sequence Types: list • L1 = [10, 20, 30, 40, 50, 60, 70] • Access the entire list → use is its name.​ • >>> Print ( L1 )​ • Access a single item → use index operator [ ] ​ • >>> L1 [ 0 ] ​ • Access part of a list → use slicing operator [ : : ]​ • >>> L1 [ 4 : 8 : 2 ]
  • 17. Python Programming Specialization Python Programming – Data Structures Sequence Data Type: tuple
  • 18. Python Programming Specialization Python Programming – Data Structures Sequence Types: tuple • Ordered collections of objects​ of same or different types • Tuples are Immutable • Examples: • >>> T1 = ( 9, 2, 13, 24 ) • >>> T2 = ( ‘Ram', 786 , 2.23, ‘Raj', 70.2 )
  • 19. Python Programming Specialization Python Programming – Data Structures Access tuple Elements • T1 = ( 10, 20, 30, 40, 50, 60, 70 ) • Access the entire tuple → use is its name.​ • >>> Print ( T1 )​ • Access a single item → use index operator [ ] ​ • >>> T1 [ 0 ] ​ • Access part of a tuple → use slicing operator [ : : ]​ • >>> T1 [ 2 : 6 : 2 ]