04 Slide
04 Slide
An object is an entity.
Each object has an id and a type.
Objects of the same kind have the same type.
You can use the id function and type function to get these
information for an object.
Method Description
isalnum() Returns True if all characters in this string are alphanumeric and there is at least
one character.
isalpha() Returns True if all characters in this string are alphabetic and there is at least
one character.
isdigit() Returns True if this string contains only number characters.
isidentifier() Returns True if this string is a Python identifier.
islower() Returns True if all characters in this string are lowercase letters and there is at
least one character.
isupper() Returns True if all characters in this string are uppercase letters and there is at
least one character.
isspace() Returns True if this string contains only whitespace characters.
Method Description
endswith(s1) Returns True if the string ends with the substring s1.
startswith(s1) Returns True if the string starts with the substring s1.
find(s1) Returns the lowest index where s1 starts in this string, or -1 if s1 is not found in
this string.
rfind(s1) Returns the highest index where s1 starts in this string, or -1 if s1 is not found
in this string.
count(subtring) Returns the number of non-overlapping occurrences of this substring.
capitalize() Returns a copy of this string with only the first character capitalized.
lower() Returns a copy of this string with all letters converted to lowercase.
upper() Returns a copy of this string with all letters converted to uppercase.
title() Returns a copy of this string with the first letter capitalized in each word.
swapcase() Returns a copy of this string in which lowercase letters are converted to uppercase
and uppercase to lowercase.
replace(old, new) Returns a new string that replaces all the occurrence of the old string with a new
string.
replace(old, new, n) Returns a new string that replaces up to n number of the occurrence of the old string
with a new string.
format(item, format-specifier)
10
□□□□□57.47
12345678.92
□□□□□57.40
□□□□□57.00
print(format(0.53457, '10.2%'))
print(format(0.0033923, '10.2%'))
print(format(7.4, '10.2%'))
10
print(format(57, '10.2%'))
□□□□53.46%
□□□□□0.34%
□□□740.00%
□□5700.00%