Loading

Quipoin Menu

Learn • Practice • Grow

python / Conditional Statements
mcq
Direction: Choose the correct option

Q1.

Which keyword is used for conditional branching in Python?
A. elif
B. if
C. else
D. All of the above
Direction: Choose the correct option

Q2.

What is the output of the following code? `if True: print('Yes') else: print('No')`
A. SyntaxError
B. YesnNo
C. No
D. Yes
Direction: Choose the correct option

Q3.

Which of the following is NOT a valid Python condition?
A. if x < 5:
B. if x > 5:
C. if x = 5:
D. if x == 5:
Direction: Choose the correct option

Q4.

What is the result of `if 0: print('True')`?
A. Prints 'False'
B. Does nothing
C. Prints 'True'
D. Raises an error
Direction: Choose the correct option

Q5.

How do you check if a variable `x` is between 5 and 10 (inclusive)?
A. if 5 <= x <= 10:
B. if x >=5 and x <=10:
C. if x in range(5,10):
D. Both A and B
Direction: Choose the correct option

Q6.

What is the purpose of `elif`?
A. To define a function
B. To end a block
C. To handle else
D. To test multiple conditions
Direction: Choose the correct option

Q7.

What will `if None:` evaluate to?
A. FALSE
B. Error
C. TRUE
Direction: Choose the correct option

Q8.

What does the `pass` statement do in a conditional block?
A. Prints nothing
B. Does nothing, acts as a placeholder
C. Exits the block
D. Throws an error
Direction: Choose the correct option

Q9.

Given `x=10`, what will `if x: print(x) else: print('no')` output?
A. 10
B. Error
C. no
D. 10nno
Direction: Choose the correct option

Q10.

Which of the following is a valid one-line conditional expression (ternary operator)?
A. if condition: x=5 else: x=10
B. Both A and B
C. x = condition ? 5 : 10
D. x = 5 if condition else 10