Bird
0
0

What will this code print?

medium📝 Predict Output Q5 of 15
Python - Conditional Statements
What will this code print?
value = 15
if value > 10:
    if value % 2 == 0:
        print('Even and >10')
    else:
        print('Odd and >10')
else:
    print('10 or less')
AOdd and >10
BEven and >10
C10 or less
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Check outer if condition

    value is 15, which is greater than 10, so outer if block runs.
  2. Step 2: Check inner if condition

    Check if 15 % 2 == 0 (even). 15 % 2 is 1, so false. Inner else runs, printing 'Odd and >10'.
  3. Final Answer:

    Odd and >10 -> Option A
  4. Quick Check:

    15 > 10 and odd prints 'Odd and >10' [OK]
Quick Trick: Check outer condition first, then inner even/odd [OK]
Common Mistakes:
MISTAKES
  • Mixing even/odd logic
  • Ignoring inner else
  • Printing outer else incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes