You are on page 1of 1

Python Lab Assignment – 7 (14/10/2022)

I. Write Python programs by using the following String Method Functions that return a
Boolean value
1. isupper() : Returns TRUE if all the if all characters in the string are uppercase.
2. islower() : Returns TRUE if all the if all characters in the string are lowercase
3. isnumeric() : Returns True if all characters in the string are numeric.
4. isalpha() : Returns True if all characters in the string are in the alphabet.
5. isacii() : Returns True if all characters in the string are ascii characters
6. isalnum() : Returns True if all characters in the string are (i.e. letter or number).
7. isdecimal() : Returns True if all characters in the string are decimals
8. isdigit() : Returns True if all characters in the string are digits.
9. isspace() : Returns True if all characters in the string are whitespaces.
10. istitle() : Returns True if the string follows the rules of a title
11. startswith() : Returns true if the string starts with the specified value
12. endswith() : Returns true if the string ends with the specified value

II. Write Python programs by using the following String Method Functions that perform
an operation on the content
1. capitalize() : Converts the first character to upper case
2. upper() : Converts a string into uppercase
3. lower() : Converts a string into lower case
4. count(‘character’) : Returns the number of times a specified character occurs in a
string.
5. find((‘character’) : Searches the string for a specified character and returns the
position of where it was found
6. center() : it returns a centered string
7. split() : Splits the string at the specified separator, and returns a list.
8. replace(‘str1’,’str2’): Returns a string where a specified string (str1) is replaced
with a specified string (str2)
9. title() : Converts the first character of each word to upper case
10. swapcase() : Swaps cases, lower case becomes upper case and vice versa

Note: All string methods returns new values. They do not change the original string.

You might also like