CBSE Class 12 Computer Science Question 71 of 105

Python Revision Tour — Question 25

Back to all questions
25
Question

Question 24

Explain the use of the pass statement. Illustrate it with an example.

Answer

The pass statement of Python is a do nothing statement i.e. empty statement or null operation statement. It is useful in scenarios where syntax of the language requires the presence of a statement but the logic of the program does not. For example,

for i in range(10):
    if i == 2:
        pass
    else:
        print("i =", i)