SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
Python strings
A QUICK RECAP
PRESENTED BY:
S.VEDA GAYATHRI
B.TECH (2nd)
Electronics and Instrumentation
engineering
NIT SILCHAR
A QUICK GLANCE OVER:
• PYTHON Strings
• Slicing Strings
• Modify Strings
• Concatenate Strings
• Format Strings
• Escape Characters
• String Methods
Python Strings
 A String is an array of characters, represented by quotation marks (‘ ’)or
double quotation marks (“ ”) .
 A string in python is a data type (str) or can also be used as a string literal.
How do we create a string and display it?
How do we create multiline strings?
Storage of strings
• Strings are stored as arrays
• Traversing through a string and accessing its elements can be done
using its indices.
• There is no character data type in python , it stores as a string of length
1.
How do we determine the length of the string?: len()
How do we check if a required word/letter is there in the
string?:keywords “in” & “not in”
How do we get the string printed in a desired range?
A[1]
A[0] A[2] A[3] A[4] A[5]
Slicing strings
• If a range of characters in a string are required slicing is used.
• The syntax for slicing is
strName[start:end]
• Here,
• strName is the name of the string
• Start is the index of the starting letter of range
• End is the index of the ending letter of range
How do we use slice syntax if we count from the end?
Negative indexing
Modify strings
• Few basic modifications that can be done to the strings
Upper() : Converts string to upper case letters
Lower(): Converts string to lower case letters
Strip(): Remove whitespaces in beginning or in the end
Replace(,): Replaces a string with another string
Split(): Seperates string if it finds a separator
• The functions are used on a particular string with a dot operator.
strName.upper()
Concatenation of strings
• Joining two different strings/data types is called Concatenation.
• Concatenation of different datatypes is not possible in python.
• This concatenation is done using ‘+’
• If two variables are of str data type they can be concatenated easily
with ‘+’
How do we perform addition of numbers with same operator?
Type Casting
How do we concatenate string and a number?
Format Strings
• Strings and the numbers can be linked using format method.
• It reserves a place for the number in the string using place holder with
curly braces { }
• The numbers are further assigned as the arguments passed through
the format()
• Values can be assigned to place holder to get the required order.
Escape Characters
• There are some illegal characters that we cannot use inside a string.
• Eg: the quotation marks , backslash etc..
• To insert the illegal characters , escape
character is used.
• It is a backslash followed by the illegal character.
• Some familiar escape characters:
Code Result
' Single Quote
 Backslash
n New Line
r Carriage Return
t Tab
b Backspace
f Form Feed
ooo Octal value
xhh Hex value
THANK YOU!!!
Queries Feedback

More Related Content

What's hot (20)

Python programming : Strings
Python programming : Strings
Emertxe Information Technologies Pvt Ltd
 
Strings in python
Strings in python
Prabhakaran V M
 
Modules and packages in python
Modules and packages in python
TMARAGATHAM
 
Chapter 07 inheritance
Chapter 07 inheritance
Praveen M Jigajinni
 
Functions in Python
Functions in Python
Kamal Acharya
 
Python Modules
Python Modules
Nitin Reddy Katkam
 
Datatypes in python
Datatypes in python
eShikshak
 
6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx
Venkateswara Babu Ravipati
 
Python : Data Types
Python : Data Types
Emertxe Information Technologies Pvt Ltd
 
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Edureka!
 
Python programming : Files
Python programming : Files
Emertxe Information Technologies Pvt Ltd
 
Functions and modules in python
Functions and modules in python
Karin Lagesen
 
Python functions
Python functions
Prof. Dr. K. Adisesha
 
Python - object oriented
Python - object oriented
Learnbay Datascience
 
Numeric Data types in Python
Numeric Data types in Python
jyostna bodapati
 
Scope rules : local and global variables
Scope rules : local and global variables
sangrampatil81
 
Chapter 14 strings
Chapter 14 strings
Praveen M Jigajinni
 
File Handling Python
File Handling Python
Akhil Kaushik
 
Conditional and control statement
Conditional and control statement
narmadhakin
 
Python-Functions.pptx
Python-Functions.pptx
Karudaiyar Ganapathy
 

Similar to Python strings presentation (20)

Python Programming-UNIT-II - Strings.pptx
Python Programming-UNIT-II - Strings.pptx
KavithaDonepudi
 
strings in python (presentation for DSA)
strings in python (presentation for DSA)
MirzaAbdullahTariq
 
Python Strings and its Featues Explained in Detail .pptx
Python Strings and its Featues Explained in Detail .pptx
parmg0960
 
Python Strings.pptx
Python Strings.pptx
adityakumawat625
 
Python data handling
Python data handling
Prof. Dr. K. Adisesha
 
trisha comp ppt.pptx
trisha comp ppt.pptx
Tapaswini14
 
PPS_Unit 4.ppt
PPS_Unit 4.ppt
KundanBhatkar
 
string manipulation in python ppt for grade 11 cbse
string manipulation in python ppt for grade 11 cbse
KrithikaTM
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3
Syed Farjad Zia Zaidi
 
Python Strings Basics with Common Methods.pptx
Python Strings Basics with Common Methods.pptx
fzafar1
 
UNIT 4 python.pptx
UNIT 4 python.pptx
TKSanthoshRao
 
varthini python .pptx
varthini python .pptx
MJeyavarthini
 
python_strings.pdf
python_strings.pdf
rajendraprasadbabub1
 
ppt notes python language operators and data
ppt notes python language operators and data
SukhpreetSingh519414
 
PROGRAMMING FOR PROBLEM SOLVING FOR STRING CONCEPT
PROGRAMMING FOR PROBLEM SOLVING FOR STRING CONCEPT
factsandknowledge94
 
Chapter05.ppt
Chapter05.ppt
afsheenfaiq2
 
Different uses of String in Python.pptx
Different uses of String in Python.pptx
AryadipDey
 
python1uhaibueuhERADGAIUSAERUGHw9uSS.pdf
python1uhaibueuhERADGAIUSAERUGHw9uSS.pdf
rohithzach
 
Python String Revisited.pptx
Python String Revisited.pptx
Chandrapriya Jayabal
 
Python strings
Python strings
Aswini Dharmaraj
 
Python Programming-UNIT-II - Strings.pptx
Python Programming-UNIT-II - Strings.pptx
KavithaDonepudi
 
strings in python (presentation for DSA)
strings in python (presentation for DSA)
MirzaAbdullahTariq
 
Python Strings and its Featues Explained in Detail .pptx
Python Strings and its Featues Explained in Detail .pptx
parmg0960
 
trisha comp ppt.pptx
trisha comp ppt.pptx
Tapaswini14
 
string manipulation in python ppt for grade 11 cbse
string manipulation in python ppt for grade 11 cbse
KrithikaTM
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3
Syed Farjad Zia Zaidi
 
Python Strings Basics with Common Methods.pptx
Python Strings Basics with Common Methods.pptx
fzafar1
 
varthini python .pptx
varthini python .pptx
MJeyavarthini
 
ppt notes python language operators and data
ppt notes python language operators and data
SukhpreetSingh519414
 
PROGRAMMING FOR PROBLEM SOLVING FOR STRING CONCEPT
PROGRAMMING FOR PROBLEM SOLVING FOR STRING CONCEPT
factsandknowledge94
 
Different uses of String in Python.pptx
Different uses of String in Python.pptx
AryadipDey
 
python1uhaibueuhERADGAIUSAERUGHw9uSS.pdf
python1uhaibueuhERADGAIUSAERUGHw9uSS.pdf
rohithzach
 
Ad

Recently uploaded (20)

Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
How the US Navy Approaches DevSecOps with Raise 2.0
How the US Navy Approaches DevSecOps with Raise 2.0
Anchore
 
Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Artificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across Industries
SandeepKS52
 
Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4
Gaurav Sharma
 
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Alluxio, Inc.
 
UPDASP a project coordination unit ......
UPDASP a project coordination unit ......
withrj1
 
GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?
felipeceotto
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
dp-700 exam questions sample docume .pdf
dp-700 exam questions sample docume .pdf
pravkumarbiz
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
Reimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AI
Maxim Salnikov
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
Plooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your way
Plooma
 
Migrating to Azure Cosmos DB the Right Way
Migrating to Azure Cosmos DB the Right Way
Alexander (Alex) Komyagin
 
Making significant Software Architecture decisions
Making significant Software Architecture decisions
Bert Jan Schrijver
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
Step by step guide to install Flutter and Dart
Step by step guide to install Flutter and Dart
S Pranav (Deepu)
 
Advanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized Innovation
arohisinghas720
 
Software Testing & it’s types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
How the US Navy Approaches DevSecOps with Raise 2.0
How the US Navy Approaches DevSecOps with Raise 2.0
Anchore
 
Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Artificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across Industries
SandeepKS52
 
Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4
Gaurav Sharma
 
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Alluxio, Inc.
 
UPDASP a project coordination unit ......
UPDASP a project coordination unit ......
withrj1
 
GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?
felipeceotto
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
dp-700 exam questions sample docume .pdf
dp-700 exam questions sample docume .pdf
pravkumarbiz
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
Reimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AI
Maxim Salnikov
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
Plooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your way
Plooma
 
Making significant Software Architecture decisions
Making significant Software Architecture decisions
Bert Jan Schrijver
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
Step by step guide to install Flutter and Dart
Step by step guide to install Flutter and Dart
S Pranav (Deepu)
 
Advanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized Innovation
arohisinghas720
 
Software Testing & it’s types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
Ad

Python strings presentation

  • 1. Python strings A QUICK RECAP PRESENTED BY: S.VEDA GAYATHRI B.TECH (2nd) Electronics and Instrumentation engineering NIT SILCHAR
  • 2. A QUICK GLANCE OVER: • PYTHON Strings • Slicing Strings • Modify Strings • Concatenate Strings • Format Strings • Escape Characters • String Methods
  • 3. Python Strings  A String is an array of characters, represented by quotation marks (‘ ’)or double quotation marks (“ ”) .  A string in python is a data type (str) or can also be used as a string literal. How do we create a string and display it? How do we create multiline strings?
  • 4. Storage of strings • Strings are stored as arrays • Traversing through a string and accessing its elements can be done using its indices. • There is no character data type in python , it stores as a string of length 1. How do we determine the length of the string?: len() How do we check if a required word/letter is there in the string?:keywords “in” & “not in” How do we get the string printed in a desired range? A[1] A[0] A[2] A[3] A[4] A[5]
  • 5. Slicing strings • If a range of characters in a string are required slicing is used. • The syntax for slicing is strName[start:end] • Here, • strName is the name of the string • Start is the index of the starting letter of range • End is the index of the ending letter of range How do we use slice syntax if we count from the end? Negative indexing
  • 6. Modify strings • Few basic modifications that can be done to the strings Upper() : Converts string to upper case letters Lower(): Converts string to lower case letters Strip(): Remove whitespaces in beginning or in the end Replace(,): Replaces a string with another string Split(): Seperates string if it finds a separator • The functions are used on a particular string with a dot operator. strName.upper()
  • 7. Concatenation of strings • Joining two different strings/data types is called Concatenation. • Concatenation of different datatypes is not possible in python. • This concatenation is done using ‘+’ • If two variables are of str data type they can be concatenated easily with ‘+’ How do we perform addition of numbers with same operator? Type Casting How do we concatenate string and a number?
  • 8. Format Strings • Strings and the numbers can be linked using format method. • It reserves a place for the number in the string using place holder with curly braces { } • The numbers are further assigned as the arguments passed through the format() • Values can be assigned to place holder to get the required order.
  • 9. Escape Characters • There are some illegal characters that we cannot use inside a string. • Eg: the quotation marks , backslash etc.. • To insert the illegal characters , escape character is used. • It is a backslash followed by the illegal character. • Some familiar escape characters: Code Result ' Single Quote Backslash n New Line r Carriage Return t Tab b Backspace f Form Feed ooo Octal value xhh Hex value