Which term describes the programming construct in which a condition is checked and its True or False result decides which block of code runs?
Selection
What is meant by elif in Python?
It adds another condition to an if statement, and its block runs only if the conditions above it were all False
What is the name for the part of an if statement, written on the same line as the if, that is checked to give a True or False result?
Condition
What is meant by nested selection?
One selection is written inside another, and the inner one is only checked when the outer condition leads to it
What is the name for the whitespace at the start of a line that shows which block the line belongs to?
Indentation
In Python, what is meant by a block of code?
The lines indented under an if, elif or else line
Which parts of an if, elif, else chain are always needed?
Only the if line and its block
What must be written at the end of an if line in Python?
A colon
In an if statement with an else part, when does the else block run?
When the condition on the if line is False
What does this program print?
Done
A student wants to add a second condition after the first if line in a selection. Which line should be written next?
elif score >= 50:
What does this program print?
Merit
The user types sun in lower case. What does this program print?
Weekday
What does this program print?
Too short to ride
In a nested selection, how must the inner if line be positioned?
Indented further than the outer if line
What happens if a program contains no selection statements?
It carries out the same steps every time it runs
A student writes Else: instead of else: in a selection. Why does the program fail to run?
The keyword must be written in lower case
In a nested selection, what happens to the inner if when the outer condition is False?
It is skipped, so its condition is never checked
A student writes if score = 70: instead of if score == 70:. What is the problem?
A single equals sign assigns a value instead of testing one
A program sets answer to a random whole number from 1 to 3, then prints Yes when answer is 1, No when it is 2, and Ask again later in the else block. What is true of one run?
The number decides which of the messages is printed
A program prints Merit for score == 50 and Fail in the else block. A score of 55 gets Fail. What change is needed?
Test score >= 50 instead of score == 50
We use cookies to enhance your experience. You can manage your preferences or learn more in our Cookie Policy.