Bird
0
0

What is the output of this code?

medium📝 Predict Output Q4 of 15
Python - Conditional Statements
What is the output of this code?
num = 7
if num > 5:
    if num < 10:
        print('A')
    else:
        print('B')
else:
    print('C')
AC
BB
CA
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Check outer if condition

    num is 7, which is greater than 5, so outer if block runs.
  2. Step 2: Check inner if condition

    Inside outer block, check if num < 10. Since 7 < 10 is true, print('A') runs.
  3. Final Answer:

    A -> Option C
  4. Quick Check:

    7 > 5 and 7 < 10 prints A [OK]
Quick Trick: Trace outer then inner conditions step-by-step [OK]
Common Mistakes:
MISTAKES
  • Confusing else blocks
  • Ignoring inner condition
  • Assuming else runs incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes