SlideShare a Scribd company logo
PythonTutorials
Lecture -3-
By: Ali Sattar
To: Everyone
Contents:
1. String Operations.
2. String Methods.
3. Examples.
There are multiple operations can be performed on strings in python, they are:
1.1 Equality: This means check two string if they both have exactly the same characters or
characters or contents and the same length. This can be done using the operator (==), for
example:
A = “Apple”; B = “Brad”; (A == B) = False; (A != B) =True
1.2 Numerical: There are two numerical operations here: Addition and Multiplication. For
For addition, it is used to concatenate a specific string with another string or substring.
For multiplication, it is used as repetitive addition to concatenate the same string with
itself according to which number is multiplied.
1. String Operations?
1. String Operations
A = “I Love”; P=“Python”; A+” ” +P = “I Love Python”;
P = “Python”; P * 4 = “PythonPythonPythonPython”
1.3 Containment: It describes a simple operator named “in” used to check if that
substring is exist in the original string or not and returns true or false.
A = “Ali Sattar”; a = “atta”; a in A =True; A in a = False
1.4 Indexing and Slicing: String in python like array in the other languages, it can be
indexed (0 – (n-1)) in a specific string on length(n), so string positions cab be accessed:
String_Name [Character_Pos]
1. String Operations
A = “Ali Sattar”; A[0] = ‘A’; A[5]= ‘a’
Strings in python unlike arrays, it can be indexed in a backward; it means we can index
from the right to left, for example:
A [-2] = ‘a’; A[-8] = ‘i’
For slicing on string, this can be done when we want to access a substring exist in the
original string and according to the following example:
A[a:b] -> A[a:b-1], where a is the start (A character in which you will start) and b-1 the
character in which you will stop ok.
A = “Python Programming”; A[3:9] = “hon pr”; A[7: ] = “Programming”
There are several methods in string, so I will try the most of them:
2.1 capitalize: It is used to convert the first letter from the your string to upper case.
2.2 right, left and center: It is used to justify your string according to field size.
2.3 count: It is used to count no. of substring repeated in the original string.
2.4 isalnum: It is return true if your string is composed of letters and numeric only. No
special symbol and other characters are not accepted here.
2.5 isalpha and isdigit: The first method return true if and only if your string is composed
composed from letters.The second method return true if and only if your string is
composed from digits.
2. String Methods
2. String Methods
2.6 isspace: This method return true if and only if your string is entirely empty “ “ or ‘’.
2.7 isupper, islower and ititle: The first method return true if your string contains a
capital letters, the second method do the opposite.The las method return true if your
string starts with an upper case letter followed by any series of lower case.
2.8 title: This method used to capitalize the first letter of each word containing in your
string.
2.9 swapcase: This method convert any upper case letter in your string to lower case and
converts the lower case to upper case too.
2.10 join: This method will join any other data type value with a string to get a string
value. There is also map method with join it will convert the current value to string
regardless of its data type.
2.11 find and index: Both of methods return the first occurrence of the given substring
or letter.
2.12 len: This method used to return the length of string (How many characters in it).
2.13 replace: This method used to replace a specific character by another character
exist in the original string.
2. String Methods
3. Examples
A = “python”; B = “python syntax is easy”; C = “%compiler%”; L = [‘1’, ‘2’, ‘3’, ‘4’];
print(B.len()) = 21 print(A.capitalize()) = “Python”
print(A.center(3)) = “ python “ print(B.count(‘s’)) = 3
print(C.isalnum()) = false print(B.isdigit()) = false
print(A.isalpha()) = true print(A.isupper()) = false
print(A.swapcase()) = “PYTHON” print(‘’.join(L)) = ‘1234’
print(‘+’.join(L)) = ‘1+2+3+4’ print(B.find(‘s’)) = 8
print(B.replace(‘s’, ‘l’) = “python lyntax il ealy”

More Related Content

What's hot

Python
PythonPython
Python
Kumar Gaurav
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in Python
Sujith Kumar
 
05 c++-strings
05 c++-strings05 c++-strings
05 c++-strings
Kelly Swanson
 
Strings
StringsStrings
Strings
Imad Ali
 
L14 string handling(string buffer class)
L14 string handling(string buffer class)L14 string handling(string buffer class)
L14 string handling(string buffer class)
teach4uin
 
Python :variable types
Python :variable typesPython :variable types
Python :variable types
S.M. Salaquzzaman
 
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++
Samsil Arefin
 
The string class
The string classThe string class
The string class
Syed Zaid Irshad
 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programming
Appili Vamsi Krishna
 
String c
String cString c
Iteration
IterationIteration
Iteration
Pooja B S
 
Strings
StringsStrings
Strings in c++
Strings in c++Strings in c++
Strings in c++
Neeru Mittal
 
Strings in C
Strings in CStrings in C
Strings in C
Kamal Acharya
 
Strings
StringsStrings
Strings
Mitali Chugh
 
Strinng Classes in c++
Strinng Classes in c++Strinng Classes in c++
Strinng Classes in c++
Vikash Dhal
 
C string
C stringC string
String.ppt
String.pptString.ppt
String.ppt
ajeela mushtaq
 
Strings
StringsStrings
Strings
Nilesh Dalvi
 
Strings In OOP(Object oriented programming)
Strings In OOP(Object oriented programming)Strings In OOP(Object oriented programming)
Strings In OOP(Object oriented programming)
Danial Virk
 

What's hot (20)

Python
PythonPython
Python
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in Python
 
05 c++-strings
05 c++-strings05 c++-strings
05 c++-strings
 
Strings
StringsStrings
Strings
 
L14 string handling(string buffer class)
L14 string handling(string buffer class)L14 string handling(string buffer class)
L14 string handling(string buffer class)
 
Python :variable types
Python :variable typesPython :variable types
Python :variable types
 
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++
 
The string class
The string classThe string class
The string class
 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programming
 
String c
String cString c
String c
 
Iteration
IterationIteration
Iteration
 
Strings
StringsStrings
Strings
 
Strings in c++
Strings in c++Strings in c++
Strings in c++
 
Strings in C
Strings in CStrings in C
Strings in C
 
Strings
StringsStrings
Strings
 
Strinng Classes in c++
Strinng Classes in c++Strinng Classes in c++
Strinng Classes in c++
 
C string
C stringC string
C string
 
String.ppt
String.pptString.ppt
String.ppt
 
Strings
StringsStrings
Strings
 
Strings In OOP(Object oriented programming)
Strings In OOP(Object oriented programming)Strings In OOP(Object oriented programming)
Strings In OOP(Object oriented programming)
 

Similar to String in python lecture (3)

ppt notes python language operators and data
ppt notes python language operators and datappt notes python language operators and data
ppt notes python language operators and data
SukhpreetSingh519414
 
Python Strings Methods
Python Strings MethodsPython Strings Methods
Python Strings Methods
Mr Examples
 
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
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and Strings
Eduardo Bergavera
 
Strings.pptx
Strings.pptxStrings.pptx
Strings.pptx
Yagna15
 
M C6java7
M C6java7M C6java7
M C6java7
mbruggen
 
Notes3
Notes3Notes3
Notes3
hccit
 
Python slide.1
Python slide.1Python slide.1
Python slide.1
Aswin Krishnamoorthy
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3Introduction To Programming with Python-3
Introduction To Programming with Python-3
Syed Farjad Zia Zaidi
 
Python data handling
Python data handlingPython data handling
Python data handling
Prof. Dr. K. Adisesha
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
Mohammed Khan
 
python_strings.pdf
python_strings.pdfpython_strings.pdf
python_strings.pdf
rajendraprasadbabub1
 
Python Built-in Functions and Use cases
Python Built-in Functions and Use casesPython Built-in Functions and Use cases
Python Built-in Functions and Use cases
Srajan Mor
 
Strings-Computer programming
Strings-Computer programmingStrings-Computer programming
Strings-Computer programming
nmahi96
 
Savitch ch 08
Savitch ch 08Savitch ch 08
Savitch ch 08
Terry Yoast
 
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docxCS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
faithxdunce63732
 
Python lec 1003_for_biologists
Python lec 1003_for_biologistsPython lec 1003_for_biologists
Python lec 1003_for_biologists
Ramadan Babers, PhD
 
C-Pubb-TestingExperience_Issue_08_2008
C-Pubb-TestingExperience_Issue_08_2008C-Pubb-TestingExperience_Issue_08_2008
C-Pubb-TestingExperience_Issue_08_2008
Berta Danilo
 
LectureNotes-04-DSA
LectureNotes-04-DSALectureNotes-04-DSA
LectureNotes-04-DSA
Haitham El-Ghareeb
 
Pointers in c language
Pointers in c languagePointers in c language
Pointers in c language
Tanmay Modi
 

Similar to String in python lecture (3) (20)

ppt notes python language operators and data
ppt notes python language operators and datappt notes python language operators and data
ppt notes python language operators and data
 
Python Strings Methods
Python Strings MethodsPython Strings Methods
Python Strings Methods
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and Strings
 
Strings.pptx
Strings.pptxStrings.pptx
Strings.pptx
 
M C6java7
M C6java7M C6java7
M C6java7
 
Notes3
Notes3Notes3
Notes3
 
Python slide.1
Python slide.1Python slide.1
Python slide.1
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3Introduction To Programming with Python-3
Introduction To Programming with Python-3
 
Python data handling
Python data handlingPython data handling
Python data handling
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
python_strings.pdf
python_strings.pdfpython_strings.pdf
python_strings.pdf
 
Python Built-in Functions and Use cases
Python Built-in Functions and Use casesPython Built-in Functions and Use cases
Python Built-in Functions and Use cases
 
Strings-Computer programming
Strings-Computer programmingStrings-Computer programming
Strings-Computer programming
 
Savitch ch 08
Savitch ch 08Savitch ch 08
Savitch ch 08
 
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docxCS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
 
Python lec 1003_for_biologists
Python lec 1003_for_biologistsPython lec 1003_for_biologists
Python lec 1003_for_biologists
 
C-Pubb-TestingExperience_Issue_08_2008
C-Pubb-TestingExperience_Issue_08_2008C-Pubb-TestingExperience_Issue_08_2008
C-Pubb-TestingExperience_Issue_08_2008
 
LectureNotes-04-DSA
LectureNotes-04-DSALectureNotes-04-DSA
LectureNotes-04-DSA
 
Pointers in c language
Pointers in c languagePointers in c language
Pointers in c language
 

Recently uploaded

The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 

Recently uploaded (20)

The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 

String in python lecture (3)

  • 2. Contents: 1. String Operations. 2. String Methods. 3. Examples.
  • 3. There are multiple operations can be performed on strings in python, they are: 1.1 Equality: This means check two string if they both have exactly the same characters or characters or contents and the same length. This can be done using the operator (==), for example: A = “Apple”; B = “Brad”; (A == B) = False; (A != B) =True 1.2 Numerical: There are two numerical operations here: Addition and Multiplication. For For addition, it is used to concatenate a specific string with another string or substring. For multiplication, it is used as repetitive addition to concatenate the same string with itself according to which number is multiplied. 1. String Operations?
  • 4. 1. String Operations A = “I Love”; P=“Python”; A+” ” +P = “I Love Python”; P = “Python”; P * 4 = “PythonPythonPythonPython” 1.3 Containment: It describes a simple operator named “in” used to check if that substring is exist in the original string or not and returns true or false. A = “Ali Sattar”; a = “atta”; a in A =True; A in a = False 1.4 Indexing and Slicing: String in python like array in the other languages, it can be indexed (0 – (n-1)) in a specific string on length(n), so string positions cab be accessed: String_Name [Character_Pos]
  • 5. 1. String Operations A = “Ali Sattar”; A[0] = ‘A’; A[5]= ‘a’ Strings in python unlike arrays, it can be indexed in a backward; it means we can index from the right to left, for example: A [-2] = ‘a’; A[-8] = ‘i’ For slicing on string, this can be done when we want to access a substring exist in the original string and according to the following example: A[a:b] -> A[a:b-1], where a is the start (A character in which you will start) and b-1 the character in which you will stop ok. A = “Python Programming”; A[3:9] = “hon pr”; A[7: ] = “Programming”
  • 6. There are several methods in string, so I will try the most of them: 2.1 capitalize: It is used to convert the first letter from the your string to upper case. 2.2 right, left and center: It is used to justify your string according to field size. 2.3 count: It is used to count no. of substring repeated in the original string. 2.4 isalnum: It is return true if your string is composed of letters and numeric only. No special symbol and other characters are not accepted here. 2.5 isalpha and isdigit: The first method return true if and only if your string is composed composed from letters.The second method return true if and only if your string is composed from digits. 2. String Methods
  • 7. 2. String Methods 2.6 isspace: This method return true if and only if your string is entirely empty “ “ or ‘’. 2.7 isupper, islower and ititle: The first method return true if your string contains a capital letters, the second method do the opposite.The las method return true if your string starts with an upper case letter followed by any series of lower case. 2.8 title: This method used to capitalize the first letter of each word containing in your string. 2.9 swapcase: This method convert any upper case letter in your string to lower case and converts the lower case to upper case too.
  • 8. 2.10 join: This method will join any other data type value with a string to get a string value. There is also map method with join it will convert the current value to string regardless of its data type. 2.11 find and index: Both of methods return the first occurrence of the given substring or letter. 2.12 len: This method used to return the length of string (How many characters in it). 2.13 replace: This method used to replace a specific character by another character exist in the original string. 2. String Methods
  • 9. 3. Examples A = “python”; B = “python syntax is easy”; C = “%compiler%”; L = [‘1’, ‘2’, ‘3’, ‘4’]; print(B.len()) = 21 print(A.capitalize()) = “Python” print(A.center(3)) = “ python “ print(B.count(‘s’)) = 3 print(C.isalnum()) = false print(B.isdigit()) = false print(A.isalpha()) = true print(A.isupper()) = false print(A.swapcase()) = “PYTHON” print(‘’.join(L)) = ‘1234’ print(‘+’.join(L)) = ‘1+2+3+4’ print(B.find(‘s’)) = 8 print(B.replace(‘s’, ‘l’) = “python lyntax il ealy”