Pass Statement in Python

Pass statement 

In python , pass statement is a null statement. Interpreter does not ignores pass statement eventually it does not do anything about pass statement.

Pass statement used to delay the time of compilation or when we do not know what code to write. In any function of a parent class which is useless to that class , but it is an useful function to it’s child classes  to avoid any error in base class then we just use pass statement.

use of pass statement in python

Implementation :

  • If there is an empty body of function or class we can use pass statement.
       def PrepInsta( ) :

           pass 

     class prepInsta :

          pass
pass statement in python

Code #1: 

  • Pass statement in function and class.
#pyhton program 
#Pass statement 
 
#we can use pass statement for an empty funtion or class 

def prepInsta():
    pass 

class prepInsta:
    pass
 


Code #2:

  • Pass statement in loop and decision making.
#pyhton program 
#Pass statement 
 
#we can use pass statement for an condition to skip

 

 b=10 
for i in range(5,12):
    if(i==b):
        pass 
    else:
        print(‘Not passed for ‘, i)
Output :

Not passed for 5
Not passed for 6
Not passed for 7
Not passed for 8
Not passed for 9
Not passed for 11