0% found this document useful (0 votes)
3 views

Class 10 Chap 5 String Manipulation II

The document provides an overview of various string manipulation functions in Python, including len(), lower(), upper(), replace(), strip(), rstrip(), lstrip(), isupper(), islower(), isdigit(), isalpha(), isalnum(), and find(). It also discusses the concepts of adding, deleting, and updating strings in Python. Additionally, it explains the use of the DEL keyword for deleting objects like strings and lists.

Uploaded by

sathyaa.m1720
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Class 10 Chap 5 String Manipulation II

The document provides an overview of various string manipulation functions in Python, including len(), lower(), upper(), replace(), strip(), rstrip(), lstrip(), isupper(), islower(), isdigit(), isalpha(), isalnum(), and find(). It also discusses the concepts of adding, deleting, and updating strings in Python. Additionally, it explains the use of the DEL keyword for deleting objects like strings and lists.

Uploaded by

sathyaa.m1720
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

String Manipulation

in
Python
Chap 5 Part II

Krish_Info_Tech
String Manipulation Functions in
Python

 Python provides various inbuilt functions, which can be


used for string manipulation.
len() Function

 len() function – to find the length


of a string. It calculates the
number of elements in the string
and returns an integer value.
 Syntax:
len(a)
a=“Krish Info Tech”
Print(len(a))
lower() Function

 Converts all the


characters of the input
string from upper case to
lower case.
 Syntax:
a.lower()
upper() Function

 Converts all the


characters of the
input string into
uppercase.
 Syntax:
a.upper()
replace() Function

 To replace a complete string


with another string.
 Syntax:
a.replace(str1,str2)
strip() Function

 If a user accidentally enters


trailing spaces or any other
characters in the beginning
or at the end of the string,
these additional objects can
be removed using strip()
function.
 Syntax:
a.strip()
rstrip() Function

To remove trailing


spaces or characters
from the right side of
the string.
Syntax:
a.rstrip(Str2)
lstrip() Function

To remove trailing


spaces or characters
from the left side of
the string.
Syntax:
a.lstrip(Str1)
isupper() Function

 Checks whether all the


characters are in uppercase.
 Function will return ‘True’ if all
the elements of the string are
in uppercase, else it will return
‘False’.
islower() Function

 Checks whether all the


characters are in lowercase.
 Function will return ‘True’ if all
the elements of the string are
in lowercase, else it will return
‘False’.
isdigit() Function

 If you need to check


whether a string consists
of digits you can use
isdigit() function.
 Syntax:
st.isdigit()
isalpha() Function

 This methods checks if


all the elements in the
string are alphabets.
 This function will return
false if encounters a
digit in the string.
 Syntax:
St.isalpha()
isalnum() Function

 Returns ‘True’ if all the


elements of the string are
alphanumeric, otherwise it
returns ‘False’.
 Syntax:
st.isalnum()
find() Function

Returns the starting


index of the
substring to be
searched within the
original string.
Syntax:
St.find(value)
Deleting a String

We can use DEL


keyword for
deleting different
objects such as
variables, strings,
and lists.
Manipulating Strings in Python

 String manipulation is the process of adding, deleting, and updating a


string.
 Addition
 We can modify a string by appending a new string to the original string.
 Concatenation operator is used
 Deletion
 This is the process of removing a part of a string.
 Range slice operator is used
 Updation
 This is the process of modifying and updating the content of a string
 Replace function is used

You might also like