SlideShare a Scribd company logo
1 of 18
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

Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9
Vince Vo
 

Similar to STRINGS IN PYTHON (20)

05 c++-strings
05 c++-strings05 c++-strings
05 c++-strings
 
STRINGS_IN_PYTHON 9-12 (1).pptx
STRINGS_IN_PYTHON 9-12 (1).pptxSTRINGS_IN_PYTHON 9-12 (1).pptx
STRINGS_IN_PYTHON 9-12 (1).pptx
 
Lecture 05 2017
Lecture 05 2017Lecture 05 2017
Lecture 05 2017
 
Character Arrays and strings in c language
Character Arrays and strings in c languageCharacter Arrays and strings in c language
Character Arrays and strings in c language
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3Introduction To Programming with Python-3
Introduction To Programming with Python-3
 
Strings in c++
Strings in c++Strings in c++
Strings in c++
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9
 
String in programming language in c or c++
String in programming language in c or c++String in programming language in c or c++
String in programming language in c or c++
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and Strings
 
Strings in Python
Strings in PythonStrings in Python
Strings in Python
 
String notes
String notesString notes
String notes
 
Team 1
Team 1Team 1
Team 1
 
Array assignment
Array assignmentArray assignment
Array assignment
 
Strings in c++
Strings in c++Strings in c++
Strings in c++
 
Strings v.1.1
Strings v.1.1Strings v.1.1
Strings v.1.1
 
Python ppt
Python pptPython ppt
Python ppt
 
Lesson in Strings for C Programming Lessons
Lesson in Strings for C Programming LessonsLesson in Strings for C Programming Lessons
Lesson in Strings for C Programming Lessons
 
Variables In Php 1
Variables In Php 1Variables In Php 1
Variables In Php 1
 
Biswa Sir Python Fundamentals.pptx
Biswa Sir Python Fundamentals.pptxBiswa Sir Python Fundamentals.pptx
Biswa Sir Python Fundamentals.pptx
 
CH6 - Fundamentals of Python.pptx
CH6 - Fundamentals of Python.pptxCH6 - Fundamentals of Python.pptx
CH6 - Fundamentals of Python.pptx
 

Recently uploaded

Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 

Recently uploaded (20)

Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 

STRINGS IN PYTHON

  • 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 !