Font size
WorksheetsDIAGNOSTIC TEST
Total questions: 41
Worksheet time: 21mins
COMPLETE: FAMILY NAME, GIVEM NAME, MIDDLE INITIALS
Multiple Choice Questions (50 items)
Direction: Read and analyze each question carefully. Choose the letter of the correct answer.
1. What is a control structure in Python?
A method to repeat code
A way to print text
A variable declaration
Controls the flow of program execution
Which of the following is a control structure?
if statement
input()
else statement
elif statement
Control structures allow programs to:
Make decisions and repeat actions
Run once
Control the programs
Execute Actions
Which of the following is NOT a type of control structure?
Declaration
Repetition
Selection
Sequential
In Python, which keyword is used for decision-making?
for
while
if
return
What is the default control flow in Python?
Random
Sequential
Conditional
Iterative
What does an if statement do?
Declares variables
Checks a condition and Ends a program
Checks a condition and executes code if true
Checks a condition and Repeats code
Which is the correct syntax of an if statement?
if condition:
if (condition);
if: condition
if condition then:
What is the output of this code?
x = 5
if x > 3:
print("Yes")
No output
Error
Yes
No
In Python, code under an if statement must be:
In quotes
In uppercase
Commented
Indented
The condition in an if statement should result in a:
String
Integer
Boolean value
Float
What happens if the condition in an if statement is false?
The program ends
An error occurs
The block still executes
The block inside if is skipped
The else clause is used when:
The if condition is true
The if condition is false
There is no condition
You want to stop the loop
What is the output?
x = 10
if x < 5:
print("Small")
else:
print("Big")
Small
Big
10
None
What keyword is paired with if in a simple decision structure?
then
when
else
case
Can else exist without an if?
Yes
No
Only inside loops
Only with functions
The else statement executes only when:
There are multiple conditions
The if block ends
The if condition is false
The if condition is true
What does elif stand for?
Else Function
End Line
Else Loop
Else If
Which of the following is correct?
if...elseif...then
if...then...else
if...else if...else
if...elif...else
What will this code output?
x = 0
if x > 0:
print("Positive")
elif x == 0:
print("Zero")
else:
print("Negative")
Positive
Error
Negative
Zero
The elif statement allows you to:
Check more than one condition
Check and Repeat code
Create loops
Stop the program
What happens if multiple conditions are true in an if-elif-else chain?
All execute
None execute
The last true one executes
The first true one executes
A nested if statement means:
Using loops
Repeating the same condition
Two unrelated if statements
One if inside another
Nested if statements are useful for:
Skipping code
Repeating code
Checking multiple related conditions
Displaying values
In a nested if, indentation shows:
Data types
The level of nesting
The order of printing
Comments
Which of the following is valid nesting?
if x > 0: if y > 0: print("Both positive")
if x > 0; if y > 0; print("Both positive")
if (x > 0, y > 0): print("Both positive")
if: x > 0 if: y > 0
A nested if can contain:
Another if
An if-else
An if-elif-else
All of the above
To test multiple conditions at once, we use:
else only
and, or operators
only if statements
print and input
What is the output?
x = 5
if x > 0 and x < 10:
print("Valid")
None
Error
Invalid
Valid
What is the output?
x = 4
if not x == 5:
print("Different")
Same
Different
Error
None
What is a list in Python?
A loop
A condition
Stores multiple values
A function
How do you create a list?
list = (1, 2, 3)
list = {1, 2, 3}
list = [1, 2, 3]
list = <1, 2, 3>
Lists are:
Immutable
Mutable
Constant
Temporary
When using if with lists, the condition evaluates to True if:
The list is not empty
The list is empty
There’s an error
None of the above
How do you combine list conditions?
Using brackets
Using commas
Using and/or operators
Using plus sign
What happens if you test a list directly in an if statement?
Causes an error
Always False
It’s True if not empty
It’s False if not empty
What is the output?
colors = ["red", "blue"]
if "green" not in colors:
print("Add green")
Skip
Error
Do nothing
Add green
What keyword is used to test membership in lists?
has
in
with
contains
Which of the following checks if a list is empty?
if len(list) == 0:
if list == empty:
if list is empty:
if size(list):
What will this code do?
numbers = [1, 2, 3]
numbers.append(4)
print(numbers)
[1, 2, 3]
[1, 2, 3, 4]
[4, 3, 2, 1]
Error
