Please enable JavaScript.
Coggle requires JavaScript to display documents.
statement, returns true is string contains only whitespace chars (space,…
statement
statement
returns true is string contains only whitespace chars (space, newline, tab)
returns true if string contains letters or digits and if string is 1<= in length
islower()
isupper()
endswith(substring)
\n
\t
\'
\''
\\
Requires
'math'
module:
Returns the arc cos. of x in rad.
acos(x)
asin(x)
random.
choice() - works with any kind of sequence
General format: :warning:
random.choice(mylist)
Requires
'random'
module:
with open(filename, 'r') as file_object:
Open a file that closes automatically
string_name.split(separator,max_split)
Using the split() method - max_split with value 1 will return back 2 elements
(if)
item in list:
(if)
item not in list:
Works for strings and lists
except ZeroDivisonError:
except:
Alternatives:
except ValueError:
except IOError:
except Exception as word_name:
print(word_name) :
finally:
try:
statement
statement
Executes whether an exception occurs or not.
else:
Executes if no exceptions were raised
file_object.method_name()
module_name.method_name()
string.method_name()
String methods:
isalnum()
isalpha()
returns true if string contains only letters and if string is 1<= in length
isdigit()
returns true if string contains only digits and if string is 1<= in length
returns true if letters are in lowercase and letters in string is 1<= in length
returns true if letters are in uppercase and letters in string is 1<= in length
isspace()
lower()
returns str. converted to lowercase
lstrip()
returns str. without whitespace chars at the start of str.
lstrip(char)
returns str. without char at the start of str.
rstrip()
returns str without whitespace chars at the end of str.
strip()
returns str. without all whitespace chars
strip(char)
returns str. without all chars
upper()
returns str. converted to uppercase
returns true if str. ends with substr.
find(substring)
returns lowest index where substr. is found, if false returns -1
replace(old, new)
returns str. with all old str. replaced by new str.
startswith(substring)
returns true if str. starts with substr.
if
name
== '
main
':
main()
if you are trying to check whether the body of a function should execute
list_name[start : end]
Returns elements/chars from start up until the end (does not include end)
string[start : end]
except IndexError
Will occur if index outside of string/list
map(function, iterable)
executes a specified function for each item in an iterable
[alignment][width][,][.precision][type]
{placeholder:format-specifier}
Escape characters:
pg298
pg273
Will occur when a file IO operation fails