pass Statement in Python — Python Technical Interview Questions & Answers

pass Statement in Python

pass Statement in Python

  • pass means do nothing. Python forbids an empty block after a colon, so pass keeps the syntax valid while you design. def todo(): pass. class Empty: pass. if ready: pass. Later you fill the body. It is not a delay and not a comment — it is a real statement that does zero work.
  • Viva: “why empty if needs pass”. Because indent + colon requires at least one statement. # comment alone is not a statement.
  • pass Statement in Python — output: Keep practising. pass lets the if-90 block exist without code yet.

Technical Interview Tip: Why empty if/def needs pass.

Code Examples for pass Statement in Python

Example

# pass
marks = 72
if marks >= 90:
    pass  # A+ later
else:
    print("Keep practising")

pass Statement in Python — output: Keep practising. pass lets the if-90 block exist without code yet.

How to Explain pass Statement in Python to an Interviewer

Explain pass Statement as if you are teaching a junior — definition, then one tiny script.

Do-nothing placeholder. Empty blocks after : need pass.

What does the example print, and why?

pass Statement in Python — output: Keep practising

What mistake do freshers make with pass Statement?

Stubs for def/class/if.