Computing · Year 4
Bell.Study
Selection: 'if' statements
Using 'if' statements to make decisions in code: 'If it is raining, take an umbrella'
- 1
What does an 'if' statement do in a program? A) Makes a decision based on whether something is true or false B) Repeats an instruction C) Stores a number D) Turns the computer off
Answer: - 2
True or false? An 'if' statement runs its action only when a condition is true. A) True B) False
Answer: - 3
'If it is raining, take an umbrella'. What is the condition? A) It is raining B) Take an umbrella C) Walk outside D) Find a hat
Answer: - 4
A condition can only be... A) True or false B) Big or small C) Hot or cold D) Open or closed
Answer: - 5
Complete the sentence about selection. An 'if' statement is also known as ___.
Answer: - 6
'If score is over 100, show YOU WIN'. When will 'YOU WIN' be shown? A) When the score is more than 100 B) When the score is exactly 100 C) When the score is less than 100 D) When the score is 0
Answer: - 7
True or false? An 'if/else' statement gives you a choice between two actions. A) True B) False
Answer: - 8
In a game: 'If lives equal 0, then game over, else keep playing'. What happens when lives = 5? A) Keep playing B) Game over C) The game freezes D) Lives reset to 0
Answer: - 9
Put these parts of an 'if' statement in the right order. Put these in order: If, the condition is true, then, do this action
Answer: - 10
Fill in the missing word. The part of an if statement that runs when the condition is false is the ___ block.
Answer:
Answer key
Selection: 'if' statements · for parents and teachers
- 1
Makes a decision based on whether something is true or false
An 'if' statement lets the program make a decision. It only runs if a condition is true.
- 2
True
True. The action inside an 'if' statement only runs if the condition is true.
- 3
It is raining
'It is raining' is the condition. If that is true, then we take an umbrella.
- 4
True or false
Conditions are always either true or false. This is called a Boolean value.
- 5
selection
Selection is the computing word for using 'if' statements to choose what to do.
- 6
When the score is more than 100
The condition is 'score is over 100'. The action only runs when the score is more than 100.
- 7
True
True. 'If' runs one action when the condition is true; 'else' runs a different action when it is false.
- 8
Keep playing
Lives = 5, so 'lives equal 0' is false. The 'else' action runs, which is 'keep playing'.
- 9
If, the condition is true, then, do this action
An 'if' statement reads like a sentence: 'If [condition], then [action]'.
- 10
else
The else block runs when the condition is false.