Python Conditional Statements - Question Paper
Section A: Multiple Choice Questions (MCQs)
Each question has four options. Choose the correct answer.
1. What will the following code output?
x = 10
if x > 5:
print("Greater than 5")
else:
print("Less than or equal to 5")
Options:
(A) Greater than 5
(B) Less than or equal to 5
(C) Error
(D) None of the above
2. What will the following code output if x = 3?
if x % 2 == 0:
print("Even")
else:
print("Odd")
Options:
(A) Even
(B) Odd
(C) None
(D) Error
3. What will the following code print?
age = 18
if age >= 18:
print("Eligible to vote")
else:
print("Not eligible to vote")
Options:
(A) Eligible to vote
(B) Not eligible to vote
(C) Error
(D) None of the above
4. Which of the following statements is true about conditional statements in Python?
(A) elif can only be used with an else statement.
(B) if statements must always be followed by an else statement.
(C) elif can be used without an else statement.
(D) if statements cannot have nested conditions.
5. Consider the following code:
x = 10
y = 20
if x > y:
print("x is greater than y")
elif x == y:
print("x is equal to y")
else:
print("x is less than y")
What will the code output?
Options:
(A) x is greater than y
(B) x is equal to y
(C) x is less than y
(D) None of the above
Section B: Predict the Output
Write the output for each of the following Python code snippets.
1. What will the following code output?
num = 7
if num % 2 == 0:
print("Even")
else:
print("Odd")
2. Predict the output of this code snippet:
a = 15
b = 10
if a > b:
if b > 5:
print("Both conditions met")
else:
print("First condition met")
else:
print("No conditions met")
3. What will the output of the following code be if x = 0?
x=0
if x > 0:
print("Positive")
elif x < 0:
print("Negative")
else:
print("Zero")
4. Consider the following code. What will it output?
temperature = 30
if temperature > 35:
print("Hot")
elif temperature > 20:
print("Warm")
else:
print("Cold")
5. What will this code print?
marks = 85
if marks >= 90:
print("Grade: A")
elif marks >= 75:
print("Grade: B")
elif marks >= 60:
print("Grade: C")
else:
print("Grade: D")