0
0
Pythonprogramming~20 mins

Elif ladder execution in Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Elif Ladder Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of elif ladder with multiple conditions
What is the output of this Python code?
Python
x = 15
if x < 10:
    print("Less than 10")
elif x < 20:
    print("Between 10 and 19")
elif x < 30:
    print("Between 20 and 29")
else:
    print("30 or more")
A30 or more
BLess than 10
CBetween 20 and 29
DBetween 10 and 19
Attempts:
2 left
💡 Hint
Check which condition is true first in the elif ladder.
Predict Output
intermediate
2:00remaining
Elif ladder with overlapping conditions
What will this code print?
Python
score = 75
if score >= 90:
    print("Grade A")
elif score >= 80:
    print("Grade B")
elif score >= 70:
    print("Grade C")
else:
    print("Grade F")
AGrade A
BGrade C
CGrade B
DGrade F
Attempts:
2 left
💡 Hint
Check conditions from top to bottom and stop at the first true one.
Predict Output
advanced
2:00remaining
Elif ladder with nested conditions
What is the output of this code?
Python
num = 0
if num > 0:
    if num % 2 == 0:
        print("Positive even")
    else:
        print("Positive odd")
elif num == 0:
    print("Zero")
else:
    print("Negative")
AZero
BPositive even
CPositive odd
DNegative
Attempts:
2 left
💡 Hint
Check the first condition and then the elif condition.
Predict Output
advanced
2:00remaining
Elif ladder with boolean expressions
What will this code print?
Python
a = True
b = False
if a and b:
    print("Both True")
elif a or b:
    print("One True")
else:
    print("None True")
ANone True
BBoth True
COne True
DSyntaxError
Attempts:
2 left
💡 Hint
Evaluate the boolean expressions carefully.
Predict Output
expert
2:00remaining
Elif ladder with variable reassignment inside conditions
What is the output of this code?
Python
x = 5
if x > 10:
    x = x + 10
    print(x)
elif x > 3:
    x = x * 2
    print(x)
else:
    x = x - 1
    print(x)
print(x)
A
10
10
B
10
15
C
10
5
D
10
20
Attempts:
2 left
💡 Hint
Check how x changes inside the elif block and then the final print.