Learn with Yasir

Share Your Feedback

Python if‑elif‑else MCQs – Multiple Choice Questions for Practice

Test your Python skills with multiple choice questions on if‑elif‑else statements. Practice conditional logic, syntax, and flow control with beginner-level Python MCQs.

Topic: if-elif-else


📝 Multiple Choice Questions

🟢 Beginner

Q1. What is the syntax for a simple if statement in Python?

  • 🟢 A. if x == 10:
  • 🔵 B. for x in range(10):
  • 🟠 C. while x < 10:
  • 🔴 D. if (x == 10) then:
Answer

if x == 10:

The correct syntax for a simple if statement in Python uses a colon at the end, like: if condition:


Q2. What is the output of the following code?

x = 10
y = 5

if x == y * 2:
    print("True")
else:
    print("False")
  • 🟢 A. True
  • 🔵 B. False
  • 🟠 C. Error
  • 🔴 D. Nothing
Answer

True

x is 10 and y*2 is also 10, so the condition is True.


Q3. What is the output of the following code?

x = 3
y = 5

if x == 3 and y != 5:
    print("True")
else:
    print("False")
  • 🟢 A. True
  • 🔵 B. False
  • 🟠 C. Syntax error
  • 🔴 D. Name error
Answer

False

x == 3 is True, but y != 5 is False, so the entire condition is False.


Q4. What will be the output of the following code?

x = 10
if  5 < x < 15:
    print("x is between 5 and 15")
else:
    print("x is not between 5 and 15")
  • 🟢 A. x is between 5 and 15
  • 🔵 B. x is not between 5 and 15
  • 🟠 C. Error
  • 🔴 D. No output
Answer

x is between 5 and 15

Python supports chained comparisons. 5 < x < 15 evaluates to True.


Q5. Which of the following correctly fixes the syntax error in the code below?

x = 10
if x == 10
    print("x is 10")
  • 🟢 A. Remove the comment.
  • 🔵 B. Add a colon after `if x == 10`.
  • 🟠 C. Add parentheses around `x == 10`.
  • 🔴 D. Indent the print statement correctly.
Answer

Add a colon after `if x == 10`.

Python requires a colon at the end of the if statement line.


🟡 Intermediate

🔴 Advanced