NEW
Font size
WorksheetsControl Structures - Selection in Python
Total questions: 11
Worksheet time: 6mins
In this python code, what message is displayed if the student scores 34?
You passed. Well done!
You failed. Try again!
Invalid score.
Syntax error
In the attached python code, what is the purpose of converting num1 and num2 to integers?
To perform string operations
To compare them as numbers
To display them as text
To store them in a list
What will be printed if num1 is 10 and num2 is 20 in the attached code?
First number is greater than the second
Second number is greater than the first
Numbers are equal
Invalid input
In this example, which part of the if-statement will be executed if the input speed is below 40 mph?
if speed >= 70:
elif speed >=40:
else:
input("Enter driver's speed")
What type of control structure is used in selection?
for loop
while loop
if-else statement
switch-case statement
In this example, what will be the output if num1 is 25 and num2 is 25?
1st bigger than 2nd
2nd bigger than 1st
Numbers are equal
No output
What is the purpose of the elif statement in an if-elif-else statement?
To handle multiple conditions
To repeat a block of code
To define a function
To initialize variables
Which programming construct does this flow chart refer to?
Selection
Sequence
Iteration (Loop)
Variable
Which statement is used to execute a block of code only if a specified condition is true?
switch statement
if statement
while loop
for loop
What will be the output if the condition in an if-else statement is false?
The code inside the if block is executed
The code inside the else block is executed
The program terminates
No output is generated
Is there an error in the attached code?
There is no error
print commands should be indented
print commands should end in colon
elif condition is missing.
