Q:

Python | Demonstrate an Example of pass statement

belongs to collection: Python basic programs

0

pass statement in python

"pass" is a type of null operation or null statement, when it executes nothing happens. It is used when you want do not want to write any code/statement to execute but syntactically a statement is required.

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Let’s consider the given example...

Here, we are using "pass" statement in the function hello() definition - there is no statement in the function and if we do not use "pass", there will be an error.

def hello():
    pass

hello()

Example 2:

for i in range(1,11):
    if(i==6):
        continue
    else:
        pass
    print(i)

Output

1
2
3
4
5
7
8
9
10

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python basic programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Python | Program to print numbers from N to 1 (use... >>
<< Python | Demonstrate an Example of continue statem...