wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Control Structures - Selection in Python

Total questions: 11

Worksheet time: 6mins

Name
Class
Date
1.

In this python code, what message is displayed if the student scores 34?

a)

You passed. Well done!

b)

You failed. Try again!

c)

Invalid score.

d)

Syntax error

2.

In the attached python code, what is the purpose of converting num1 and num2 to integers?

a)

To perform string operations

b)

To compare them as numbers

c)

To display them as text

d)

To store them in a list

3.

What will be printed if num1 is 10 and num2 is 20 in the attached code?

a)

First number is greater than the second

b)

Second number is greater than the first

c)

Numbers are equal

d)

Invalid input

4.

In this example, which part of the if-statement will be executed if the input speed is below 40 mph?

a)

if speed >= 70:

b)

elif speed >=40:

c)

else:

d)

input("Enter driver's speed")

5.

What type of control structure is used in selection?

a)

for loop

b)

while loop

c)

if-else statement

d)

switch-case statement

6.

In this example, what will be the output if num1 is 25 and num2 is 25?

a)

1st bigger than 2nd

b)

2nd bigger than 1st

c)

Numbers are equal

d)

No output

7.

What is the purpose of the elif statement in an if-elif-else statement?

a)

To handle multiple conditions

b)

To repeat a block of code

c)

To define a function

d)

To initialize variables

8.

Which programming construct does this flow chart refer to?

a)

Selection

b)

Sequence

c)

Iteration (Loop)

d)

Variable

9.

Which statement is used to execute a block of code only if a specified condition is true?

a)

switch statement

b)

if statement

c)

while loop

d)

for loop

10.

What will be the output if the condition in an if-else statement is false?

a)

The code inside the if block is executed

b)

The code inside the else block is executed

c)

The program terminates

d)

No output is generated

11.

Is there an error in the attached code?

a)

There is no error

b)

print commands should be indented

c)

print commands should end in colon

d)

elif condition is missing.