Question Detail

COS 102 6 lecture note; fundamentals of programming Objective Question

Question

What is the purpose of the pass statement in Python?
Options
A To skip a block of code and generate an error.
B To indicate a placeholder where a statement is syntactically required but no action is desired.
Correct Answer
C To terminate the program immediately.
D To repeat a block of code a specified number of times.
Correct Answer

Option B is the correct answer.

Detailed Explanation

Page 101 explains: 'The pass statement in Python is used when a statement is required syntactically but you do not want any command or code to execute. The pass statement is a null operation; nothing happens when it executes.'

Hint

Think of it as a 'do nothing' instruction that satisfies syntax requirements.

Question Info