0
0
Pythonprogramming~20 mins

Pass statement usage in Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Pass Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of pass in a loop
What is the output of this code snippet?
Python
for i in range(3):
    pass
print('Done')
ASyntaxError
B0 1 2
CDone
DNone
Attempts:
2 left
💡 Hint
The pass statement does nothing but is syntactically needed.
Predict Output
intermediate
2:00remaining
Pass in function definition
What will be the output of this code?
Python
def greet():
    pass
print(greet())
Agreet
BNone
CSyntaxError
D'' (empty string)
Attempts:
2 left
💡 Hint
Functions without return return None by default.
Predict Output
advanced
2:00remaining
Pass in conditional blocks
What is the output of this code?
Python
x = 5
if x > 10:
    print('Greater')
else:
    pass
print('Done')
ADone
B
Greater
Done
CSyntaxError
DNo output
Attempts:
2 left
💡 Hint
pass does nothing but allows empty blocks.
Predict Output
advanced
2:00remaining
Pass in class definition
What will this code print?
Python
class Empty:
    pass

obj = Empty()
print(type(obj))
A<class '__main__.Empty'>
BSyntaxError
C<class 'object'>
DNone
Attempts:
2 left
💡 Hint
pass allows empty class bodies.
Predict Output
expert
2:00remaining
Pass effect on function behavior
What is the output of this code?
Python
def func():
    if False:
        pass
    else:
        return 'Hello'

print(func())
ANone
Bpass
CSyntaxError
DHello
Attempts:
2 left
💡 Hint
pass does nothing and does not affect flow.