Conditional Statements Questions and Answers
Practice ModeShowing 10 of 25 questions
Q1
Which keyword is used to start an if statement in Python?
Answer: Option B
Explanation: The "if" keyword is used to start conditional statements in Python.
Q2
What is the correct syntax for an if statement in Python?
Answer: Option C
Explanation: In Python, if statements end with a colon and the code block is indented.
Q3
Which keyword is used for alternative conditions in an if statement?
Answer: Option C
Explanation: The "elif" keyword is used for else-if conditions in Python.
Q4
What will be the output of: x = 5; if x > 3: print("Hello")
Answer: Option A
Explanation: Since x=5 is greater than 3, the condition evaluates to True and "Hello" is printed.
Q5
Which operator is used for logical AND in Python?
Answer: Option C
Explanation: The "and" operator is used for logical AND operations in Python.
Q6
What is the purpose of the else clause in an if statement?
Answer: Option C
Explanation: The else clause executes when all previous conditions are False.
Q7
Which of these is a valid conditional expression?
Answer: Option B
Explanation: Conditional expressions should use proper Python syntax with comparison operators.
Q8
What will be the output of: x = 2; if x > 5: print("A") elif x > 1: print("B") else: print("C")
Answer: Option B
Explanation: x=2 is not greater than 5, but it is greater than 1, so "B" is printed.
Q9
Which operator is used for logical OR in Python?
Answer: Option C
Explanation: The "or" operator is used for logical OR operations in Python.
Q10
What is the result of: if not False: print("True")
Answer: Option A
Explanation: not False evaluates to True, so the print statement executes.