wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

DIAGNOSTIC TEST

Total questions: 41

Worksheet time: 21mins

Name
Class
Date
1.

COMPLETE: FAMILY NAME, GIVEM NAME, MIDDLE INITIALS

4 lines
2.

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)

A method to repeat code

b)

A way to print text

c)

A variable declaration

d)

Controls the flow of program execution

3.

Which of the following is a control structure?

a)

if statement

b)

input()

c)

else statement

d)

elif statement

4.

Control structures allow programs to:

a)

Make decisions and repeat actions

b)

Run once

c)

Control the programs

d)

Execute Actions

5.

Which of the following is NOT a type of control structure?

a)

Declaration

b)

Repetition

c)

Selection

d)

Sequential

6.

In Python, which keyword is used for decision-making?

a)

for

b)

while

c)

if

d)

return

7.

What is the default control flow in Python?

a)

Random

b)

Sequential

c)

Conditional

d)

Iterative

8.

What does an if statement do?

a)

Declares variables

b)

Checks a condition and Ends a program

c)

Checks a condition and executes code if true

d)

Checks a condition and Repeats code

9.

Which is the correct syntax of an if statement?

a)

if condition:

b)

if (condition);

c)

if: condition

d)

if condition then:

10.

What is the output of this code?
x = 5

if x > 3:

print("Yes")

a)

No output

b)

Error

c)

Yes

d)

No

11.

In Python, code under an if statement must be:

a)

In quotes

b)

In uppercase

c)

Commented

d)

Indented

12.

The condition in an if statement should result in a:

a)

String

b)

Integer

c)

Boolean value

d)

Float

13.

What happens if the condition in an if statement is false?

a)

The program ends

b)

An error occurs

c)

The block still executes

d)

The block inside if is skipped

14.

The else clause is used when:

a)

The if condition is true

b)

The if condition is false

c)

There is no condition

d)

You want to stop the loop

15.

What is the output?
x = 10

if x < 5:

print("Small")

else:

print("Big")

a)

Small

b)

Big

c)

10

d)

None

16.

What keyword is paired with if in a simple decision structure?

a)

then

b)

when

c)

else

d)

case

17.

Can else exist without an if?

a)

Yes

b)

No

c)

Only inside loops

d)

Only with functions

18.

The else statement executes only when:

a)

There are multiple conditions

b)

The if block ends

c)

The if condition is false

d)

The if condition is true

19.

What does elif stand for?

a)

Else Function

b)

End Line

c)

Else Loop

d)

Else If

20.

Which of the following is correct?

a)

if...elseif...then

b)

if...then...else

c)

if...else if...else

d)

if...elif...else

21.

What will this code output?
x = 0

if x > 0:

print("Positive")

elif x == 0:

print("Zero")

else:

print("Negative")

a)

Positive

b)

Error

c)

Negative

d)

Zero

22.

The elif statement allows you to:

a)

Check more than one condition

b)

Check and Repeat code

c)

Create loops

d)

Stop the program

23.

What happens if multiple conditions are true in an if-elif-else chain?

a)

All execute

b)

None execute

c)

The last true one executes

d)

The first true one executes

24.

A nested if statement means:

a)

Using loops

b)

Repeating the same condition

c)

Two unrelated if statements

d)

One if inside another

25.

Nested if statements are useful for:

a)

Skipping code

b)

Repeating code

c)

Checking multiple related conditions

d)

Displaying values

26.

In a nested if, indentation shows:

a)

Data types

b)

The level of nesting

c)

The order of printing

d)

Comments

27.

Which of the following is valid nesting?

a)

if x > 0: if y > 0: print("Both positive")

b)

if x > 0; if y > 0; print("Both positive")

c)

if (x > 0, y > 0): print("Both positive")

d)

if: x > 0 if: y > 0

28.

A nested if can contain:

a)

Another if

b)

An if-else

c)

An if-elif-else

d)

All of the above

29.

To test multiple conditions at once, we use:

a)

else only

b)

and, or operators

c)

only if statements

d)

print and input

30.

What is the output?
x = 5

if x > 0 and x < 10:

print("Valid")

a)

None

b)

Error

c)

Invalid

d)

Valid

31.

What is the output?
x = 4

if not x == 5:

print("Different")

a)

Same

b)

Different

c)

Error

d)

None

32.

What is a list in Python?

a)

A loop

b)

A condition

c)

Stores multiple values

d)

A function

33.

How do you create a list?

a)

list = (1, 2, 3)

b)

list = {1, 2, 3}

c)

list = [1, 2, 3]

d)

list = <1, 2, 3>

34.

Lists are:

a)

Immutable

b)

Mutable

c)

Constant

d)

Temporary

35.

When using if with lists, the condition evaluates to True if:

a)

The list is not empty

b)

The list is empty

c)

There’s an error

d)

None of the above

36.

How do you combine list conditions?

a)

Using brackets

b)

Using commas

c)

Using and/or operators

d)

Using plus sign

37.

What happens if you test a list directly in an if statement?

a)

Causes an error

b)

Always False

c)

It’s True if not empty

d)

It’s False if not empty

38.

What is the output?
colors = ["red", "blue"]

if "green" not in colors:

print("Add green")

a)

Skip

b)

Error

c)

Do nothing

d)

Add green

39.

What keyword is used to test membership in lists?

a)

has

b)

in

c)

with

d)

contains

40.

Which of the following checks if a list is empty?

a)

if len(list) == 0:

b)

if list == empty:

c)

if list is empty:

d)

if size(list):

41.

What will this code do?
numbers = [1, 2, 3]

numbers.append(4)

print(numbers)

a)

[1, 2, 3]

b)

[1, 2, 3, 4]

c)

[4, 3, 2, 1]

d)

Error