AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Selection in Scratch

Week 14 · Unit 6: Be an animator · 3 lessons
1

If this, then do that

Computing 5: Unit 6, pp. 70–85
GoalSay what selection is and name the condition and the conclusion in an if … then statement.
New words
selection · a decision in a program: it checks a condition and chooses what to docondition · a question that is either true or falseconclusion · the steps that are carried out only when the condition is trueif … then · a statement that runs its conclusion only when its condition is true
Explanation

Selection means that a program makes a decision. An if … then statement has two parts. The condition comes after ‘if’. It is a question that is either true or false. The conclusion comes after ‘then’. It is carried out only when the condition is true. If the condition is false, the program skips the conclusion and goes on. We make these decisions every day: ‘If it is dark, then I switch on the lamp.’ In Scratch the if block holds the condition in its pointed slot, and the blocks inside it are the conclusion.

whenclickedsayHop!for1secondsifkeyspacepressed?thenforever
Worked examples
StatementConditionConclusion
If it is dark, then I switch on the lamp.it is darkI switch on the lamp
If the shop has bread, then we buy two loaves.the shop has breadwe buy two loaves
If the match is cancelled, then the team goes home.the match is cancelledthe team goes home
Each of these everyday statements has a condition and a conclusion.
Starttouching the cheese?yesnosay Yum!End
The condition decides the path. When the answer is yes (true), the conclusion is carried out. When it is no (false), the program skips it.
whenclickedgo to x:-120y:-40move100stepssayYum!for2secondsstart soundPopiftouchingCheese?then
Here is a small program. The Mouse goes to x: -120, y: -40 and moves 100 steps, so it ends at x: -20. The Cheese sits at x: -20, y: -40. The Mouse is touching the Cheese, so the condition is true. The if block holds two blocks, and both of them are the conclusion: the Mouse says ‘Yum!’ and the pop sound plays.
Class activity

Card checker (3 or more players). One player is the checker. The checker holds a rule card such as ‘If the card shows an even number, then say Yes!’. The other players hold number cards and show them one at a time. The checker says the conclusion only when the condition is true, and stays silent when it is false. Swap roles and invent new rules, for example about colours or animals. For each rule, point to the condition and the conclusion.

Practice
1
Find the condition and the conclusion. (a) If I finish my reading, then I can draw. (b) If the pool is closed, then we go to the park.
2
The flag is clicked and the left arrow key is not being pressed. What does the sprite do?
whenclickedchange x by-10ifkeyleft arrowpressed?then
3
Write your own if … then statement about a game or a sport. Underline the condition and circle the conclusion.
4
Sort these blocks into conditions and conclusions.
touchingTree?sayOuch!for2secondskeyspacepressed?hide