SlideShare a Scribd company logo
6
Most read
15
Most read
18
Most read
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

PPT
Introduction to Python
PPTX
R Programming Language
PPTX
Data Structures in Python
PPTX
Facebook Marketing Presentation.
PPT
MVC ppt presentation
PDF
Management Information System James O Brien Study Notes
PDF
Genetic Algorithm (GA) Optimization - Step-by-Step Example
PPTX
Classification Algorithm.
Introduction to Python
R Programming Language
Data Structures in Python
Facebook Marketing Presentation.
MVC ppt presentation
Management Information System James O Brien Study Notes
Genetic Algorithm (GA) Optimization - Step-by-Step Example
Classification Algorithm.

What's hot (20)

PPTX
Python strings presentation
PPTX
Types of methods in python
PPTX
Python Functions
PDF
Python-02| Input, Output & Import
PDF
Multidimensional arrays in C++
PDF
Python basic
PPTX
Introduction python
PPTX
Packages In Python Tutorial
PPT
Java buzzwords
PDF
Zero to Hero - Introduction to Python3
PPTX
Conditional and control statement
PPTX
Full Python in 20 slides
PPT
Data members and member functions
PPT
Data Structures and Algorithm Analysis
PPTX
Introduction to data structure ppt
PPTX
Python basics
PPSX
Modules and packages in python
PPS
Interface
PPTX
Static Data Members and Member Functions
PPTX
Type casting
Python strings presentation
Types of methods in python
Python Functions
Python-02| Input, Output & Import
Multidimensional arrays in C++
Python basic
Introduction python
Packages In Python Tutorial
Java buzzwords
Zero to Hero - Introduction to Python3
Conditional and control statement
Full Python in 20 slides
Data members and member functions
Data Structures and Algorithm Analysis
Introduction to data structure ppt
Python basics
Modules and packages in python
Interface
Static Data Members and Member Functions
Type casting
Ad

Similar to Python Sequence Data types in Brief (20)

PDF
Python Programminng…………………………………………………..
PPTX
intro to python.pptx
PPTX
Introduction to Python Programming for beginners
PPTX
Programming in Python
PPTX
IOT notes,................................
PPTX
Python programming
PPTX
Python_IoT.pptx
PPTX
PYTHON DATA TYPE in python using v .pptx
PPTX
Python-Basics.pptx
PPTX
INTRODUCTION TO PYTHON.pptx
PPTX
PYTHON DATA TYPE IN PROGRAMMING LANG.pptx
PPTX
AI_2nd Lab.pptx
PPTX
Presentation on python data type
PPTX
PPT on Python - illustrating Python for BBA, B.Tech
PDF
Python bootcamp - C4Dlab, University of Nairobi
PPTX
fundamental of python --- vivek singh shekawat
PPT
Python ppt
PDF
Datatypes in python
PPTX
Python programming
PDF
Stacks in Python will be made using lists.pdf
Python Programminng…………………………………………………..
intro to python.pptx
Introduction to Python Programming for beginners
Programming in Python
IOT notes,................................
Python programming
Python_IoT.pptx
PYTHON DATA TYPE in python using v .pptx
Python-Basics.pptx
INTRODUCTION TO PYTHON.pptx
PYTHON DATA TYPE IN PROGRAMMING LANG.pptx
AI_2nd Lab.pptx
Presentation on python data type
PPT on Python - illustrating Python for BBA, B.Tech
Python bootcamp - C4Dlab, University of Nairobi
fundamental of python --- vivek singh shekawat
Python ppt
Datatypes in python
Python programming
Stacks in Python will be made using lists.pdf
Ad

Recently uploaded (20)

PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Introduction and Scope of Bichemistry.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PDF
Open folder Downloads.pdf yes yes ges yes
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Pharma ospi slides which help in ospi learning
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Module 3: Health Systems Tutorial Slides S2 2025
PDF
English Language Teaching from Post-.pdf
PPTX
How to Manage Starshipit in Odoo 18 - Odoo Slides
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Introduction and Scope of Bichemistry.pptx
human mycosis Human fungal infections are called human mycosis..pptx
Open Quiz Monsoon Mind Game Final Set.pptx
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
Open folder Downloads.pdf yes yes ges yes
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Pharma ospi slides which help in ospi learning
Anesthesia in Laparoscopic Surgery in India
O7-L3 Supply Chain Operations - ICLT Program
Module 3: Health Systems Tutorial Slides S2 2025
English Language Teaching from Post-.pdf
How to Manage Starshipit in Odoo 18 - Odoo Slides
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
NOI Hackathon - Summer Edition - GreenThumber.pptx

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 ]