Python Reserved Words 2.7

when we talk about python identifiers those used to declare variables, functions and etc.. we need to know that there is python reserved words 2.7 we can not use..

let’s list them

python reserved words 2.7

and       del       from      not       while
as        elif      global    or        with
assert    else      if        pass      yield
break     except    import    print
class     exec      in        raise
continue  finally   is        return
def       for       lambda    try

and

is an logical operator, used in condition testing and not very common in use

as

another one of python reserved words 2.7, it used with import statement, it gives the ability to add a library and give it a name to be used in your code

assert

this helps you find bugs quick and easy by checking, it will be explained later

break

break statement is used to escape code scope, most common use case is with functions and loops

class

it do as it says, it used to declare classes, you will work with it over and over again

continue

it’s more related to break statement, actually it just do the opposite job

def

more like class, used to define functions, you will see it so much specially if you one of functional programming lovers

del

the bad guy is del, it used to delete things like functions and variables and even classes, watch out xD

elif + if + else

oh man, you are mixing things up.. watch out

i meant to, why ? it’s so much related stuff – okay how ? let’s see

if statement puts interpreter in front of two choices and interpreter should choose based on condition test.

okay, what about elif, let me tell you

elif puts him on other choice if the first went false.

oh man, and else.. else just doing some code if either of them went true, learn more

except + try

mixing stuff again, it’s cool man, let’s see..

python has some built-in exceptions, okay. what if exception shows up then those statements catches it and handling this

exec

used to run an app and ber important one of python reserved words 2.7

finally

belongs to try, except. so there is no way the exception corrupt something

for

used for looping and iterating in sequences, learn more

from + import

used to get modules and libraries to our code, as import (module) from (package).

global

used to declare global variable inside private block of code.

in

it used for membership check, like element in a list

is

it used for identity check

lambda

A lambda function is a small anonymous function.

A lambda function can take any number of arguments, but can only have one expression.

not + or

is an logical operators, used in condition testing and not very common in use

pass

used to pass some block of code like functions

print

the famous function that prints something on screen

raise

it’s categorized under errors directory, so it could be helpful with try, and those keywords

return

statement causes your function to exit and hand back a value to its caller. The point of functions in general is to take in inputs and return something.

while

looping method doing stuff while iteration or condition is true, learn more

with

simple statement solving problems, details later on

yield

To understand what does, you must understand what generators are. And before generators come iter, so it’ll be explained later on