Save
OOP Midterms
Save
Share
Learn
Content
Leaderboard
Learn
Created by
maganda
Visit profile
Cards (144)
Strings
are arrays of bytes representing
Unicode characters.
Strings are
immutable
(cannot be changes one it has been assigned).
Strings are created by enclosing characters inside a
single
or
double
quote.
Indexing
allows access to individual characters.
Slicing
allows access to a range of characters.
Elements of string can be accessed using
square
brackets.
String
length
or
len
() is used to determine the length of a string.
String
concatenation
is a string operation that joins two or more strings together.
You can check if a string contains a specific substring using "
in
".
A
method
is defined with respect to a particular object.
Syntax: object.method(argument)
capitalize
() method capitalizes the first letter of a string.
upper()
method capitalizes all the characters.
lower()
method returns all strings in lower case.
lstrip()
removes left padded spaces in string.
rstrip()
removes right padded spaces in string.
strip()
removes any whitespaces in string
title()
converts given string into title case.
swapcase
() is toggle the case (from upper to lower and lower to upper)
ljust
() is used to add spaces to the left of a string
rjust
() is used to add spaces to the right of a string
center(width,fillchair)
returns centered in a string of length width.
The default filler of center() method is
space.
zfill()
is used to fill the zero to a given string.
find()
is used to find a particular character/ string in a given string.
count()
is used to count the number of times a character/string appears in a given string.
startswith()
is used to check if a string starts with a particular character.
endswith()
is used to check if a string ends with a particular character.
isdigit(
) is used to check if the string is a digit.
isnumeric
() is used to check if the string is a digit(number)
islower()
is used to check if all the characters in a string is in lower case
isupper
() is used to check if string contains all upper case
isspace
() is used to check if a string contains a space ONLY
str
() is used to convert non-string data intro string data
max
() is used to get a max alphabet of string.
max("Airam") =
r
min()
is used to get the min alphabet of string.
min("Airam") =
a
Triple
quotes are used to represent multiline strings and docstrings.
split()
is used to split strings into multiple strings according to the delimeter.
index()
same as find() but raises an exception if string is not found
See all 144 cards