Conditional Statements Questions and Answers
Practice ModeShowing 10 of 25 questions
Q11
Which of these checks if a number is between 1 and 10 inclusive?
Answer: Option D
Explanation: The "and" operator can combine multiple conditions.
Q12
What will be the output of: x = 0; if x: print("Yes") else: print("No")
Answer: Option B
Explanation: In Python, 0 evaluates to False in boolean context.
Q13
Which operator has the highest precedence in conditional expressions?
Answer: Option D
Explanation: Parentheses have the highest precedence and can be used to control evaluation order.
Q14
What is the purpose of nested if statements?
Answer: Option B
Explanation: Nested if statements allow checking multiple conditions in a hierarchical manner.
Q15
What will be the output of: x = "hello"; if x: print("Yes") else: print("No")
Answer: Option A
Explanation: Non-empty strings are truthy in Python.
Q16
Which of these is NOT a valid way to check if a list is empty?
Answer: Option D
Explanation: Comparing a list directly to False is not the correct way to check if it is empty.
Q17
What does the "pass" keyword do in an if statement?
Answer: Option B
Explanation: The pass statement is a null operation used as a placeholder.
Q18
What will be the output of: x = 10; if x > 5 and x < 15: print("In range")
Answer: Option A
Explanation: Both conditions are True, so the message is printed.
Q19
Which of these is the correct syntax for if-elif-else?
Answer: Option C
Explanation: Python uses elif for else-if conditions, not elseif or else if.
Q20
What is short-circuit evaluation in conditional expressions?
Answer: Option B
Explanation: Short-circuit evaluation stops evaluating as soon as the result is determined.