SlideShare a Scribd company logo
SEQUENCES
PRESENTED BY:
DHANUSHYA V
INDHUMATHI M
III BCA A
WHAT IS SEQUENCE?
• A sequence is a collection of objects, arranged in a particular order. A
sequence can be either a list, a tuple, or a string. Sequences are
inerrable, meaning you can loop over the elements in a sequence
one by one.
• Sequences are containers with items stored in a deterministic
ordering. Each sequence data type comes with its unique capabilities.
SEQUENCE TYPE OPERATORS
Sequence Operator Function
seq[ind] Element located at index ind of seq
seq[ind1:ind2] Elements from ind1 up to but not including ind2 of seq
seq * expr seq repeated expr times
seq1 + seq2 Concatenates sequences seq1 and seq2
obj in seq Tests if obj is a member of sequence seq
obj not in seq Tests if obj is not a member of sequence seq
TYPES OF SQUENCES
THERE ARE SIX TYPES OF SEQUENCES NAMELY;
1. STRING
2. LIST
3. TUPLES
4. BYTES SEQUENCES
5. BYTE ARRAYS
6. RANGE()OBJECTS
STRINGS
• Strings in python are surrounded by either single quotation marks, or double
quotation marks.
• 'hello' is the same as "hello". We can create string using str()function also.
• We can literally display string with print()statement;
• Example: Creating a string
print(“Hello”)
print(‘hello’)
HOW TO ACCESS VALUES
• Assigning a string to a variable is done with the variable name followed by an equal sign
and the string:
Example:
>>>a = "Hello"
>>>print(a)
Output:
Hello
>>>a[1:5]
Output:
"ello"
UPDATE A STRING
• You can “update” an existing string by (re)assigning a variable to another
string
>>> aString = aString[:6] + 'Python!’
>>> aString
'Hello Python!’
REMOVE A STRING
• strings are immutable, so you cannot remove individual characters from an existing
string.
Example:
>>> aString = ‘’
>>> aString
‘’
>>>del aString
MULTILINE STRINGS
• You can assign a multiline string to a variable by using three
quotes:
Example:
a = """welcome all ,
Good to see you all,
Good morning"""
print(a)
STRINGS ARE ARRAYS
• strings in Python are arrays of bytes representing Unicode
characters. Python does not have a character data type.
• Square brackets can be used to access elements of the
string.
Example: a = "Hello, World!"
print(a[1])
PYTHON - STRING METHODS
• Python has a set of built-in methods that you can use on
strings.
Method Description
capitalize() Converts the first character to upper case
casefold() Converts string into lower case
center() Returns a centered string
count() Returns the number of times a specified value occurs in a string
lower() Converts a string into lower case
replace() Returns a string where a specified value is replaced with a
specified value
split() Splits the string at the specified separator, and returns a list
LIST
• Lists are used to store multiple items in a single variable.
• Lists are one of 4 built-in data types in Python used to store
collections of data.
• Lists are created using square brackets.
Example: Creating a list,
LIST ITEMS
• List items are ordered, changeable, and allow duplicate values.
Ordered:
• When we say that lists are ordered, it means that the items
have a defined order, and that order will not change.
• If you add new items to a list, the new items will be placed at
the end of the list
CHANGEABLE
• The list is changeable, meaning that we can change, add, and
remove items in a list after it has been created.
ALLOW DUPLICATES
• Since lists are indexed, lists can have items with the same value:
Example:
LIST LENGTH
• To determine how many items a list has,use len()function;
Example
Print the number of items in the list:
TUPLE
• Tuples are used to store multiple items in a single variable.
• A tuple is a collection which is ordered and unchangeable.
• Tuples are written with round brackets.
Example
• Create a Tuple:
UPDATE TUPLE
• Tuple items are ordered, unchangeable, and allow duplicate
values.
Example:
TUPLE METHODS
METHOD DESCRIPTION
count() Returns the number of times a specified value occurs in a tuple
index() Searches the tuple for a specified value and returns the position of where it was found
THANK YOU

More Related Content

Similar to "Sequences in Python include list, tuple, string, and range" (20)

PPTX
Datastrucure
Mohamed Essam
 
PDF
Processing data with Python, using standard library modules you (probably) ne...
gjcross
 
PPTX
Arrays in Reading.pptx
EdFeranil
 
PDF
ProgPrinc_Lecture_3_Data_Structures_and_Iteration-2.pdf
lailoesakhan
 
PPTX
Python Tutorial Part 1
Haitham El-Ghareeb
 
PPTX
Python Collections
sachingarg0
 
PDF
ProgFund_Lecture_3_Data_Structures_and_Iteration-1.pdf
lailoesakhan
 
PPTX
Data Structures in Python
Devashish Kumar
 
PPT
Python first day
MARISSTELLA2
 
PPT
Python first day
farkhand
 
PPTX
Computer Sience, This is my presentation for beginners coding in python
alin173596
 
PPTX
Stacks.pptx in software engineering in simple understanding
MohammedAnas871930
 
PPTX
Tuples.pptx
AnuragBharti27
 
PDF
The List Data Model
Darío Garigliotti
 
PDF
"Automata Basics and Python Applications"
ayeshasiraj34
 
PPTX
02 Python Data Structure.pptx
ssuser88c564
 
PPTX
Lists, Stacks, and Queues: Abstract Data Types
Hasan Dwi Cahyono
 
PPTX
11 Introduction to lists.pptx
ssuser8e50d8
 
PPTX
Python
reshmaravichandran
 
PPTX
pythondatatypes.pptx
ArchanaAravind1
 
Datastrucure
Mohamed Essam
 
Processing data with Python, using standard library modules you (probably) ne...
gjcross
 
Arrays in Reading.pptx
EdFeranil
 
ProgPrinc_Lecture_3_Data_Structures_and_Iteration-2.pdf
lailoesakhan
 
Python Tutorial Part 1
Haitham El-Ghareeb
 
Python Collections
sachingarg0
 
ProgFund_Lecture_3_Data_Structures_and_Iteration-1.pdf
lailoesakhan
 
Data Structures in Python
Devashish Kumar
 
Python first day
MARISSTELLA2
 
Python first day
farkhand
 
Computer Sience, This is my presentation for beginners coding in python
alin173596
 
Stacks.pptx in software engineering in simple understanding
MohammedAnas871930
 
Tuples.pptx
AnuragBharti27
 
The List Data Model
Darío Garigliotti
 
"Automata Basics and Python Applications"
ayeshasiraj34
 
02 Python Data Structure.pptx
ssuser88c564
 
Lists, Stacks, and Queues: Abstract Data Types
Hasan Dwi Cahyono
 
11 Introduction to lists.pptx
ssuser8e50d8
 
pythondatatypes.pptx
ArchanaAravind1
 

Recently uploaded (20)

PDF
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
PDF
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 
PDF
Proactive Server and System Monitoring with FME: Using HTTP and System Caller...
Safe Software
 
PDF
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
 
PDF
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
PDF
Why aren't you using FME Flow's CPU Time?
Safe Software
 
PDF
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
PDF
Plugging AI into everything: Model Context Protocol Simplified.pdf
Abati Adewale
 
PDF
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
PDF
Bridging CAD, IBM TRIRIGA & GIS with FME: The Portland Public Schools Case
Safe Software
 
PPTX
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
PPTX
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
PDF
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
PDF
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
PDF
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
PDF
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
PDF
Understanding AI Optimization AIO, LLMO, and GEO
CoDigital
 
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 
Proactive Server and System Monitoring with FME: Using HTTP and System Caller...
Safe Software
 
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
 
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
Why aren't you using FME Flow's CPU Time?
Safe Software
 
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
Plugging AI into everything: Model Context Protocol Simplified.pdf
Abati Adewale
 
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
Bridging CAD, IBM TRIRIGA & GIS with FME: The Portland Public Schools Case
Safe Software
 
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
Understanding AI Optimization AIO, LLMO, and GEO
CoDigital
 
Ad

"Sequences in Python include list, tuple, string, and range"

  • 2. WHAT IS SEQUENCE? • A sequence is a collection of objects, arranged in a particular order. A sequence can be either a list, a tuple, or a string. Sequences are inerrable, meaning you can loop over the elements in a sequence one by one. • Sequences are containers with items stored in a deterministic ordering. Each sequence data type comes with its unique capabilities.
  • 3. SEQUENCE TYPE OPERATORS Sequence Operator Function seq[ind] Element located at index ind of seq seq[ind1:ind2] Elements from ind1 up to but not including ind2 of seq seq * expr seq repeated expr times seq1 + seq2 Concatenates sequences seq1 and seq2 obj in seq Tests if obj is a member of sequence seq obj not in seq Tests if obj is not a member of sequence seq
  • 4. TYPES OF SQUENCES THERE ARE SIX TYPES OF SEQUENCES NAMELY; 1. STRING 2. LIST 3. TUPLES 4. BYTES SEQUENCES 5. BYTE ARRAYS 6. RANGE()OBJECTS
  • 5. STRINGS • Strings in python are surrounded by either single quotation marks, or double quotation marks. • 'hello' is the same as "hello". We can create string using str()function also. • We can literally display string with print()statement; • Example: Creating a string print(“Hello”) print(‘hello’)
  • 6. HOW TO ACCESS VALUES • Assigning a string to a variable is done with the variable name followed by an equal sign and the string: Example: >>>a = "Hello" >>>print(a) Output: Hello >>>a[1:5] Output: "ello"
  • 7. UPDATE A STRING • You can “update” an existing string by (re)assigning a variable to another string >>> aString = aString[:6] + 'Python!’ >>> aString 'Hello Python!’
  • 8. REMOVE A STRING • strings are immutable, so you cannot remove individual characters from an existing string. Example: >>> aString = ‘’ >>> aString ‘’ >>>del aString
  • 9. MULTILINE STRINGS • You can assign a multiline string to a variable by using three quotes: Example: a = """welcome all , Good to see you all, Good morning""" print(a)
  • 10. STRINGS ARE ARRAYS • strings in Python are arrays of bytes representing Unicode characters. Python does not have a character data type. • Square brackets can be used to access elements of the string. Example: a = "Hello, World!" print(a[1])
  • 11. PYTHON - STRING METHODS • Python has a set of built-in methods that you can use on strings. Method Description capitalize() Converts the first character to upper case casefold() Converts string into lower case center() Returns a centered string count() Returns the number of times a specified value occurs in a string lower() Converts a string into lower case replace() Returns a string where a specified value is replaced with a specified value split() Splits the string at the specified separator, and returns a list
  • 12. LIST • Lists are used to store multiple items in a single variable. • Lists are one of 4 built-in data types in Python used to store collections of data. • Lists are created using square brackets. Example: Creating a list,
  • 13. LIST ITEMS • List items are ordered, changeable, and allow duplicate values. Ordered: • When we say that lists are ordered, it means that the items have a defined order, and that order will not change. • If you add new items to a list, the new items will be placed at the end of the list
  • 14. CHANGEABLE • The list is changeable, meaning that we can change, add, and remove items in a list after it has been created. ALLOW DUPLICATES • Since lists are indexed, lists can have items with the same value: Example:
  • 15. LIST LENGTH • To determine how many items a list has,use len()function; Example Print the number of items in the list:
  • 16. TUPLE • Tuples are used to store multiple items in a single variable. • A tuple is a collection which is ordered and unchangeable. • Tuples are written with round brackets. Example • Create a Tuple:
  • 17. UPDATE TUPLE • Tuple items are ordered, unchangeable, and allow duplicate values. Example:
  • 18. TUPLE METHODS METHOD DESCRIPTION count() Returns the number of times a specified value occurs in a tuple index() Searches the tuple for a specified value and returns the position of where it was found