Name:
Roll No:
Class: SY BCA Science - E
String Methods
Sr.No. Methods Description Code & Output
1. Capitalize() Capitalizes first Code:
letter of string
Output:
2. count(str, beg= 0, end=len(string)) Counts how many Code:
times str occurs in
string or in a Output:
substring of string
if starting
index beg and
ending index end
are
given.
3. endswith(suffix, beg=0, Determines if Code:
end=len(string)) string or a
substring of Output:
string (if starting
index beg and
ending
index end are
given) ends with
suffix;
returns true if so
and false
otherwise.
4. isalnum() Returns true if Code:
string has at least
1 Output:
character and all
characters are
alphanumeric and
false otherwise.
5. isalpha() Returns true if Code:
string has at least
1
character and all Output:
characters are
alphabetic
and false
otherwise.
6. isdigit() Returns true if Code:
string contains
only digits Output:
and false
otherwise.
7. islower() Returns true if Code:
string has at least
1 cased Output:
character and all
cased characters
are in
lowercase and
false otherwise.
8. isnumeric() Returns true if a Code:
unicode string
contains
only numeric Output:
characters and
false
otherwise.
9. isspace() Returns true if Code:
string contains
only Output:
whitespace
characters and
false
otherwise.
10. istitle() Returns true if Code:
string is properly
"titlecased" and Output:
false otherwise.
11. isupper() Returns true if Code:
string has at least
one Output:
cased character
and all cased
characters
are in uppercase
and false
otherwise.
12. join(seq) Merges Code:
(concatenates) the
string Output:
representations of
elements in
sequence
seq into a string,
with separator
string.
13. len(string) Returns the length Code:
of the string.
Output:
14. ljust(width[, fillchar]) Returns a space- Code:
padded string with
the Output:
original string left-
justified to a total
of
width columns.
15. lower() Converts all Code:
uppercase letters
in string to Output:
lowercase.
16. lstrip() Removes all Code:
leading
whitespace in Output:
string.
17. maketrans() Returns a Code:
translation table to
be used in Output:
translate function.
18. max(str) Returns the max Code:
alphabetical
character Output:
from the string str.
19. min(str) Returns the min Code:
alphabetical
character Output:
from the string str.
20. replace(old, new [, max]) Replaces all Code:
occurrences of old
in string Output:
with new or at
most max
occurrences if
max given.
21. rfind(str, beg=0,end=len(string)) Same as find(), Code:
but search
backwards in Output:
string.
22. rjust(width,[, fillchar]) Returns a space- Code:
padded string with
the Output:
original string
right-justified to a
total of
width columns.
23. rstrip() Removes all Code:
trailing whitespace
of string. Output:
24. split(str="", num=string.count(str)) Splits string Code:
according to
delimiter str Output:
(space if not
provided) and
returns list of
substrings; split
into at most num
substrings if given.
25. splitlines( num=string.count('\n')) Splits string at all Code:
(or num)
NEWLINEs Output:
and returns a list
of each line with
NEWLINEs
removed.
26. swapcase() Inverts case for all Code:
letters in string.
Output:
27. title() Returns Code:
"titlecased"
version of string, Output:
that
is, all words begin
with uppercase
and the
rest are
lowercase.
28. translate(table, deletechars="") Translates string Code:
according to
translation Output:
table str(256
chars), removing
those in
the del string.
29. upper() Converts Code:
lowercase letters
in string to Output:
uppercase.
30. zfill (width) Returns original Code:
string left padded
with zeros to a Output:
total of width
characters;
intended for
numbers, zfill()
retains any
sign given (less
one zero).
31. isdecimal() Returns true if a Code:
unicode string
contains Output:
only decimal
characters and
false
otherwise.
Tuple Functions
Serial Function Description Code & Output
No.
1. all() Return True if all elements of Code:
the tuple are true (or if the
tuple is empty). Output:
2. any() Return True if any element of Code:
the tuple is true. If the tuple is
empty, return False.
Output:
3. enumerate() Return an enumerate object. Code:
It contains the index and
value of all the items of tuple
as pairs. Output:
4. len() Return the length (the number Code:
of items) in the tuple.
Output:
5. max() Return the largest item in the Code:
tuple.
Output:
6. min() Return the smallest item in Code:
the tuple.
Output:
7. sorted() Take elements in the tuple Code:
and return a new sorted list
(does not sort the tuple itself).
Output:
8. sum() Return the sum of all Code:
elements in the tuple.
Output:
9. tuple() Convert an iterable (list, Code:
string, set, dictionary) to a
tuple.
Output:
Date: Signature