Menu

Selection

Card 1 of 22 0 got it 0 still learning
Question
TapClick or press space to see the answer
Answer
All 22 cards in this set
What is the name for the way a program decides which blocks of code to run based on conditions?
Selection
What is meant by 'elif' in Python?
A keyword that checks another condition when earlier ones are not met
What is the name for the test on an if line that decides whether the indented code will run?
Condition
What is meant by 'else' in Python?
A keyword that runs its code when the if condition has not been met
What is the name for a decision that is placed inside another decision in a program?
Nested if
What is meant by 'indentation' in Python?
The spaces at the start of a line that show which block it is in
In a Python condition, what does the symbol != check?
Whether two values are different
What does the symbol <= mean in a Python condition?
Less than or equal to
In a Python condition, what does the symbol == check?
Whether two values are the same
What must come at the end of every if, elif and else line?
A colon
A program outputs Pass when the score is greater than 50 and Fail in every other case. What does it output for a score of 50?
Fail
A quiz prints Brilliant for a score above 75, Great for a score above 50 and Okay for a score above 25, otherwise Low. What is printed for a score of 80?
Brilliant
Why is int() used around a value typed by the user before it is compared with a number?
It converts the text typed in into a whole number
A program says Hello Elizabeth! only when the name typed in is Elizabeth. The user types elizabeth instead. What happens?
Nothing is printed because the text must match exactly
What happens to code written after an if and else block if it is not indented?
It runs whatever the result of the condition was
A nested if asks a second question only when the first answer is door. The user answers window instead. What happens next?
No second question is asked and nothing is printed
The condition int(age) >= 13 decides whether Teen is shown. Which ages show Teen?
13 and every age above 13
A pupil writes Else: on a line instead of else:. Why will the line not work?
Because if, elif and else must be in lowercase
A pupil wants two messages printed when a condition is met. How should the two print lines be written?
Both indented by the same amount under the if line
Why do most programs use selection?
So they can react differently depending on the data
A pupil writes an if line, then an else line, then an elif line. Why will this not work?
An elif line must come before the else line
A program has an if line and two elif lines but no else. What happens when none of the three conditions is met?
None of the blocks run and the program carries on