Bird
0
0

What will be the output of this Python code?

medium📝 Predict Output Q13 of 15
Python - Basics and Execution Environment
What will be the output of this Python code?
if 5 > 2:
    print('Yes')
else:
    print('No')
ANo
BYes
C5 > 2
DSyntaxError
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate the condition 5 > 2

    Since 5 is greater than 2, the condition is True.
  2. Step 2: Follow the if-else logic

    Because the condition is True, the code inside the if block runs, printing 'Yes'.
  3. Final Answer:

    Yes -> Option B
  4. Quick Check:

    5 > 2 is True, so output = Yes [OK]
Quick Trick: Check if condition is true or false to pick output [OK]
Common Mistakes:
MISTAKES
  • Confusing indentation causing SyntaxError
  • Choosing 'No' instead of 'Yes'
  • Thinking code prints the condition itself

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes