WorksheetsConditional Statements in Python Quiz-9a
Total questions: 10
Worksheet time: 5mins
Name
Class
Date
1.
What is the primary purpose of conditional statements in programming?
a)
To control the flow of a program
b)
To store data
c)
To create loops
d)
To define functions
2.
Which of the following is the correct syntax for an if statement in Python?
a)
if condition: statement
b)
if: condition statement
c)
if condition then statement
d)
if (condition) { statement }
3.
In an if-elif-else statement, what happens if the first condition is false?
a)
The program stops
b)
The next elif condition is evaluated
c)
The else block is executed immediately
d)
The program returns an error
4.
What is the output of the following code snippet if the user inputs 4? if num % 2 == 0: print('Even') else: print('Odd')
a)
Even
b)
Odd
c)
Error
d)
None
5.
Which statement correctly describes a nested conditional statement?
a)
A condition within another condition
b)
A statement that runs in a loop
c)
A statement that does not require indentation
d)
A statement that only checks one condition
6.
What will the following code output if age = 20? if age < 18: print('Minor') elif age < 65: print('Adult') else: print('Senior')
a)
Minor
b)
Adult
c)
Senior
d)
Error
7.
In the context of conditional statements, what does 'elif' stand for?
a)
Else if
b)
Else in
c)
End if
d)
Execute if
8.
Which of the following statements is true regarding the 'else' clause?
a)
It is mandatory in conditional statements
b)
It executes when all previous conditions are false
c)
It can only be used with if statements
d)
It cannot contain any code
9.
What is the output of the following code snippet? if 5 > 3: print('Five is greater') else: print('Three is greater')
a)
Five is greater
b)
Three is greater
c)
Error
d)
None
10.
Which of the following is NOT a valid comparison operator in Python?
a)
==
b)
!=
c)
=>
d)
<
100 %
