Bird
0
0

What will be the output of this code?

medium📝 Predict Output Q4 of 15
Python - Conditional Statements
What will be the output of this code?
num = 7
if num % 2 == 0:
    print('Even')
else:
    print('Odd')
AOdd
BEven
C0
DError
Step-by-Step Solution
Solution:
  1. Step 1: Calculate num % 2

    7 % 2 equals 1, which is not zero, so condition is False.
  2. Step 2: Determine which block runs

    Since condition is False, else block runs and prints 'Odd'.
  3. Final Answer:

    Output is 'Odd' because 7 is not divisible by 2. -> Option A
  4. Quick Check:

    Odd number triggers else block [OK]
Quick Trick: If remainder is zero, number is even [OK]
Common Mistakes:
MISTAKES
  • Confusing remainder calculation
  • Assuming 7 is even

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes