Python Syntax Review Flashcards
del
deletes objects, i.e. from lists or dictionaries
global
takes an object declared outside a function and uses it within that function
assert
figures out if a certain criteria is met, and if it is not, prints an AssertionError
pass
passes the code from the current iteration of a for-loop to the code following it within the loop
continue
sends a for-loop to the next iteration without executing the code that follows it within the loop
yield
maintains the status of a function while returning a value in that state of the function
break
stops a loop from continuing to run
class
used to create a new object class
exec
executes a string of text as code
raise
raises an exception
finally
at the end of a try block, runs code no matter which branch of the block was followed
lambda
used to establish a one-off function anonymously
%d
decimal format
%i
integer format
%o
octal format
%u
unsigned decimal integer format
%x
lowercase hexadecimal format
%X
uppercase hexidecimal format
%e
lowercase exponential format
%E
uppercase exponential format
%f
floating point decimal format
%F
floating point decimal format
%g
same as e if exponent is greater than -4 or less than precision, f otherwise
%G
same as E if exponent is greater than -4 or less than precision, f otherwise
%c
single character format
\a
ASCII bel
\b
ASCII backspace
\f
ASCII Formfeed
\n
ASCII Linefeed
\r
ASCII Carriage Return
\t
ASCII horizontal tab
\v
ASCII vertical tab
,
creates a tuple, which is a list of values separated by commas
:
slice syntax which “slices out” sub parts in sequences