Keywords are pre-defined words in a Python compiler.
Each keyword is meant to perform some specific function in a Python program.
Since keywords are referred as a name for compiler, they can’t be used as variable name because it has standard predefined specific meaning.
Since Python is case sensitive, Keywords should be written in lower case.
The meaning and working of these keywords are already known to the compiler and therefore, it can not be changed or modified.
print 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.
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 executed, unless the condition is True
is tests 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 a 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 user 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