SlideShare a Scribd company logo
GROUP
PRESENTATION
GROUP MEMBERS
╸ xxxxx
╸ xxxxx
╸ xxxxx
╸ xxxxx
╸ xxxxx
2
3
CONTENTS
╸ >>> Introduction
╸ >>> Definition
╸ >>> Creating
╸ >>> Indexing
╸ >>> Slicing
╸ >>> Concatenation
╸ >>> String Formatting
╸ >>> Escape Characters
╸ >>> String Methods
4
INTRODUCTION
Initially when we started of learning about python, we dealt
more with numbers, technically integers;
But, in our real world, we tend to use a lot of sentences
than just numbers.
All these so called sentences are what we call “strings”.
5
DEFINITION
6
ᴓ Python string is the collection of the characters surrounded by single quotes,
double quotes, or triple quotes.
ᴓ The computer does not understand the characters; internally, it stores
manipulated character as the combination of the 0's and 1’s.
ᴓ Unlike some other languages, python doesn’t support char datatype, so strings
can be assumed as a list of char.
ᴓ Each character is encoded in the ASCII or Unicode character. So we can say
that Python strings are also called the collection of Unicode characters.
CREATING A STRING :
7
OUTPUT :
• A string can be used directly into the print statement as well…
• As python has inbuilt ‘str’ datatype, when use the python script to find
database, it outputs as ‘str’
INDEXING IN A STRING
8
• Each element of a string can be accessed and dealt with
separately using the concept of indexing.
• Square brackets can be used to access the elements of a string.
Find the output for the above code snippet ^^^
Again all these are the concept of considering ‘str’ as list of
‘char’.
With this same concept, we can even loop through all the
characters in a particular string.
SLICING OF STRINGS
9
 We can return a range of characters by using the slice syntax / operation
 We need to specify the start index and the end index, separated by a colon, to return the
part of the string
 Remember index values always start from zero (0)
 For Example; OUTPUT
 We can also use the indices to print characters in a particular pattern. We need to add
another value called a step value next to the stop value.
 If required even negative index can be used.
STRING CONCATENATION
╸ To concatenate more than a string, we can simply use + operator
╸ Example ;
10
STRING FORMATTING
• As we know we cannot combine different datatypes, without
typecasting.
• We can use the format() method, it takes passed arguments, formats
them and places them in the string where the placeholders { } are;
• This way, we can take a unlimited number of arguments and place
them in the string accordingly.
• We can number the placeholders for clarity
12
ILLUSTRATION :
OUTPUT :
ESCAPE CHARACTERS
13
 To insert characters that are illegal in a string, use an escape character
 An escape character is a ‘  ‘ backslash followed by the character you want to
insert
 For an example, if you want to use quotations inside a string, the interpreter
will misunderstand and throw an error, Instead use the escape characters just
before the required character to avoid that.
ERROR ;
CORRECTION ;
Some of the common escape characters used are mentioned below ;
14
>>> ’ - to use a single quote
>>> ” - to use a double quote
>>> n - to start in a new line
>>> t - to leave a tab space
>>> b - to do a backspace
>>> ooo - to use a octal value
>>> xhh - to use a hexadecimal value
STRING METHODS
15
Unlike other programming languages, python provides a
huge catalogue of features and inbuilt operations to make
the job easier;
16
 capitalize() – converts the first character to upper case
 upper() – converts a string into upper case
 lower() – converts a string into lower case
 title() – converts the first character of every word to upper case
 strip() – removes all the spaces to the left and right of a string
 startswith() – returns true, if string starts with a specified value
 split() – splits the string at the specified separator and returns a list
 replace() – replaces a specified value with another value
 isalpha() – returns true, if all the characters are alphabets
 isupper() – returns true, if all the characters are in upper case
 islower() - returns true, if all the characters are in lower case
 count() – returns the number of times a specified character occurs
CREDITS and REFERENCES
Special thanks to all the people who made and released these
awesome resources for free:
╸ Presentation template by SlidesCarnival
╸ Photographs by Unsplash
╸ Illustrations by Pixsellz
╸ Images by Google Images
╸ Content by javatpoint.com and w3schools.com
17
We appreciate everyone for
spending your valuable time and
attention … : )
18
THANK YOU !

More Related Content

Similar to strings in python (presentation for DSA) (20)

PPTX
Python Programming-UNIT-II - Strings.pptx
KavithaDonepudi
 
PPTX
varthini python .pptx
MJeyavarthini
 
PPTX
Different uses of String in Python.pptx
AryadipDey
 
PDF
Strings3a4esrxdfgcbhjjjjjiiol;lkljiojoii
pawankamal3
 
PPTX
Day5 String python language for btech.pptx
mrsam3062
 
PPTX
Python Strings.pptx
adityakumawat625
 
PPTX
trisha comp ppt.pptx
Tapaswini14
 
PPTX
Python Strings and strings types with Examples
Prof. Kartiki Deshmukh
 
PDF
Unit 1-Part-3 - String Manipulation.pdf
Harsha Patil
 
PPTX
Chapter 11 Strings and methods [Autosaved].pptx
geethar79
 
PDF
BCSE101E_Python_Module5 (4).pdf
mukeshb0905
 
PDF
Python- strings
Krishna Nanda
 
PPTX
PROGRAMMING FOR PROBLEM SOLVING FOR STRING CONCEPT
factsandknowledge94
 
PPT
PPS_Unit 4.ppt
KundanBhatkar
 
PPTX
STRINGS_IN_PYTHON 9-12 (1).pptx
Tinku91
 
PDF
ppt notes python language operators and data
SukhpreetSingh519414
 
PDF
‘How to develop Pythonic coding rather than Python coding – Logic Perspective’
S.Mohideen Badhusha
 
PPTX
string manipulation in python ppt for grade 11 cbse
KrithikaTM
 
PPTX
stringggg.pptxtujd7ttttttttttttttttttttttttttttttttttt
pawankamal3
 
PPTX
Python Strings.pptx
M Vishnuvardhan Reddy
 
Python Programming-UNIT-II - Strings.pptx
KavithaDonepudi
 
varthini python .pptx
MJeyavarthini
 
Different uses of String in Python.pptx
AryadipDey
 
Strings3a4esrxdfgcbhjjjjjiiol;lkljiojoii
pawankamal3
 
Day5 String python language for btech.pptx
mrsam3062
 
Python Strings.pptx
adityakumawat625
 
trisha comp ppt.pptx
Tapaswini14
 
Python Strings and strings types with Examples
Prof. Kartiki Deshmukh
 
Unit 1-Part-3 - String Manipulation.pdf
Harsha Patil
 
Chapter 11 Strings and methods [Autosaved].pptx
geethar79
 
BCSE101E_Python_Module5 (4).pdf
mukeshb0905
 
Python- strings
Krishna Nanda
 
PROGRAMMING FOR PROBLEM SOLVING FOR STRING CONCEPT
factsandknowledge94
 
PPS_Unit 4.ppt
KundanBhatkar
 
STRINGS_IN_PYTHON 9-12 (1).pptx
Tinku91
 
ppt notes python language operators and data
SukhpreetSingh519414
 
‘How to develop Pythonic coding rather than Python coding – Logic Perspective’
S.Mohideen Badhusha
 
string manipulation in python ppt for grade 11 cbse
KrithikaTM
 
stringggg.pptxtujd7ttttttttttttttttttttttttttttttttttt
pawankamal3
 
Python Strings.pptx
M Vishnuvardhan Reddy
 

Recently uploaded (20)

PPTX
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PPTX
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
PPTX
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PPTX
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
PPTX
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
PPTX
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
PPTX
Knowledge Representation : Semantic Networks
Amity University, Patna
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PPT
Testing and final inspection of a solar PV system
MuhammadSanni2
 
PDF
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
PPTX
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
PDF
Data structures notes for unit 2 in computer science.pdf
sshubhamsingh265
 
PPTX
Distribution reservoir and service storage pptx
dhanashree78
 
PDF
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
PPTX
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
PPTX
Biosensors, BioDevices, Biomediccal.pptx
AsimovRiyaz
 
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
Design Thinking basics for Engineers.pdf
CMR University
 
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
Knowledge Representation : Semantic Networks
Amity University, Patna
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
Testing and final inspection of a solar PV system
MuhammadSanni2
 
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
Data structures notes for unit 2 in computer science.pdf
sshubhamsingh265
 
Distribution reservoir and service storage pptx
dhanashree78
 
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
Biosensors, BioDevices, Biomediccal.pptx
AsimovRiyaz
 
Ad

strings in python (presentation for DSA)

  • 2. GROUP MEMBERS ╸ xxxxx ╸ xxxxx ╸ xxxxx ╸ xxxxx ╸ xxxxx 2
  • 3. 3
  • 4. CONTENTS ╸ >>> Introduction ╸ >>> Definition ╸ >>> Creating ╸ >>> Indexing ╸ >>> Slicing ╸ >>> Concatenation ╸ >>> String Formatting ╸ >>> Escape Characters ╸ >>> String Methods 4
  • 5. INTRODUCTION Initially when we started of learning about python, we dealt more with numbers, technically integers; But, in our real world, we tend to use a lot of sentences than just numbers. All these so called sentences are what we call “strings”. 5
  • 6. DEFINITION 6 ᴓ Python string is the collection of the characters surrounded by single quotes, double quotes, or triple quotes. ᴓ The computer does not understand the characters; internally, it stores manipulated character as the combination of the 0's and 1’s. ᴓ Unlike some other languages, python doesn’t support char datatype, so strings can be assumed as a list of char. ᴓ Each character is encoded in the ASCII or Unicode character. So we can say that Python strings are also called the collection of Unicode characters.
  • 7. CREATING A STRING : 7 OUTPUT : • A string can be used directly into the print statement as well… • As python has inbuilt ‘str’ datatype, when use the python script to find database, it outputs as ‘str’
  • 8. INDEXING IN A STRING 8 • Each element of a string can be accessed and dealt with separately using the concept of indexing. • Square brackets can be used to access the elements of a string. Find the output for the above code snippet ^^^ Again all these are the concept of considering ‘str’ as list of ‘char’. With this same concept, we can even loop through all the characters in a particular string.
  • 9. SLICING OF STRINGS 9  We can return a range of characters by using the slice syntax / operation  We need to specify the start index and the end index, separated by a colon, to return the part of the string  Remember index values always start from zero (0)  For Example; OUTPUT  We can also use the indices to print characters in a particular pattern. We need to add another value called a step value next to the stop value.  If required even negative index can be used.
  • 10. STRING CONCATENATION ╸ To concatenate more than a string, we can simply use + operator ╸ Example ; 10
  • 11. STRING FORMATTING • As we know we cannot combine different datatypes, without typecasting. • We can use the format() method, it takes passed arguments, formats them and places them in the string where the placeholders { } are; • This way, we can take a unlimited number of arguments and place them in the string accordingly. • We can number the placeholders for clarity
  • 13. ESCAPE CHARACTERS 13  To insert characters that are illegal in a string, use an escape character  An escape character is a ‘ ‘ backslash followed by the character you want to insert  For an example, if you want to use quotations inside a string, the interpreter will misunderstand and throw an error, Instead use the escape characters just before the required character to avoid that. ERROR ; CORRECTION ;
  • 14. Some of the common escape characters used are mentioned below ; 14 >>> ’ - to use a single quote >>> ” - to use a double quote >>> n - to start in a new line >>> t - to leave a tab space >>> b - to do a backspace >>> ooo - to use a octal value >>> xhh - to use a hexadecimal value
  • 15. STRING METHODS 15 Unlike other programming languages, python provides a huge catalogue of features and inbuilt operations to make the job easier;
  • 16. 16  capitalize() – converts the first character to upper case  upper() – converts a string into upper case  lower() – converts a string into lower case  title() – converts the first character of every word to upper case  strip() – removes all the spaces to the left and right of a string  startswith() – returns true, if string starts with a specified value  split() – splits the string at the specified separator and returns a list  replace() – replaces a specified value with another value  isalpha() – returns true, if all the characters are alphabets  isupper() – returns true, if all the characters are in upper case  islower() - returns true, if all the characters are in lower case  count() – returns the number of times a specified character occurs
  • 17. CREDITS and REFERENCES Special thanks to all the people who made and released these awesome resources for free: ╸ Presentation template by SlidesCarnival ╸ Photographs by Unsplash ╸ Illustrations by Pixsellz ╸ Images by Google Images ╸ Content by javatpoint.com and w3schools.com 17
  • 18. We appreciate everyone for spending your valuable time and attention … : ) 18 THANK YOU !