Python Keywords

Keywords and Definitions

while

controlling the flow of the program

for

iterate over items of a collection in order that they appear

break

interrupt the loop

continue

continue to the next iteration of a loop

if

make a conditional statement

else

Used in conditional statements

elif

same as else if

is

tests for object identity

not

conditions have not been met

and

conditions in a boolean expression have been met

or

at least one condition has been met

import

import modules or libraries

as

create an alias

from

import variable,class or function

def

creates a new user defined function

return

returns a value

lambda

creates an anonymous function

global

access variables outside of a function

try

to try

except

what to do when an exception occurs

finally

executed in the end

raise

user defined exception

del

delete

pass

do nothing

assert

For debugging

class

used to create new user defined objects

exec

executes Python code

yield

 returns a generator