Python Keywords Flashcards
print to console
while
Controlling the flow of the program
for
Iterate over items of a collection in order that they appear
break
Interrupt the (loop) cycle, if needed
continue
Used to interrupt the current cycle, without jumping out of the whole cycle. New cycle will begin.
if
Used to determine, which statements are going to be executed (conditional)
elif
Stands for else if, if the first test evaluates to False, then it continues with the next one.
else
Is optional. The statement after the else keyword is excuted, unless the condition is True
is
Tets for object identity
not
Negates a boolean value
and
All conditions in a boolean expression must be met
or
At least one condition must be met
import
Import other modules into Python script
as
If we want to give a module a different alias
from
For importing a specific variable, class or a function from a module
def
Used to create a new defined function
return
Exits the function and returns a value
lambda
Creates a new anonymous function
global
access variables defined outside functions
try
Specifies exception handlers
except
Catches the exception and executes codes
finally
Is always executed in the end. Used to clean up resources
raise
Create a user defined exception
del
deletes objects
pass
Does nothing
assert
Used for debugging purposes
class
Used to create new user defined objects
exec
Executes Python code dynamically
yield
Is used with generators