1 Answers
📚 Quick Study Guide
- 💡 'If-Then' Block: Executes a set of instructions only if a specified condition is true. If the condition is false, the instructions inside the block are skipped, and the script continues with the next block.
- ⚙️ Purpose of 'If-Then': Ideal for situations where you want a single, specific action to occur based on whether a condition is met (e.g., "If touching color red, then stop all sounds").
- 🔄 'If-Then-Else' Block: Provides two distinct paths for your script. It executes one set of instructions if the condition is true, and a *different* set of instructions if the condition is false.
- 🎯 Purpose of 'If-Then-Else': Best suited for scenarios where you need to perform one action if a condition is true and a *different* action if the condition is false (e.g., "If score > 10, then say 'You win!', else say 'Try again!'").
- ⚖️ Key Difference: 'If-Then' offers a single conditional action or nothing. 'If-Then-Else' always offers two mutually exclusive actions based on the condition's truth value.
- ✅ Conditions: Both blocks rely on Boolean (true/false) conditions, often created using Sensing blocks (e.g., `touching [mouse-pointer]?`) or Operators (e.g., `<(score) > (10)>`).
- 🖥️ Scratch Logic: Understanding these blocks is fundamental for creating interactive games and animations where sprite behavior changes based on user input or game state.
❓ Practice Quiz
1. What is the primary function of an 'If-Then' block in Scratch?
A. To execute a set of commands only if a condition is false.
B. To execute a set of commands repeatedly as long as a condition is true.
C. To execute a set of commands once if a specified condition is true.
D. To execute one set of commands if a condition is true, and another set if it's false.
2. When would you typically use an 'If-Then-Else' block instead of an 'If-Then' block?
A. When you only want something to happen if a condition is met.
B. When you need to choose between two different actions based on a single condition.
C. When you want to loop a command until a condition becomes false.
D. When you want to stop all other scripts if a condition is true.
3. Consider a Scratch script: "If (key [space] pressed?) Then (change x by 10)". What happens if the space key is NOT pressed?
A. The sprite will change x by -10.
B. The script will pause indefinitely.
C. The 'change x by 10' command will be skipped.
D. The program will stop running.
4. A game needs to show "You Win!" if the score is over 100, and "Keep Playing!" otherwise. Which block is most appropriate?
A. An 'If-Then' block.
B. An 'If-Then-Else' block.
C. A 'Repeat Until' block.
D. A 'Forever' block.
5. In an 'If-Then-Else' block, if the condition evaluates to false, which part of the block's code is executed?
A. The commands within the 'Then' section.
B. The commands within the 'Else' section.
C. Both the 'Then' and 'Else' sections simultaneously.
D. Neither section, and the script stops.
6. Which of the following conditions would typically be found in an 'If-Then' or 'If-Then-Else' block in Scratch?
A. `move (10) steps`
B. `say (Hello!)`
C. `(score) > (50)`
D. `wait (1) seconds`
7. What happens if you place an 'If-Then' block inside the 'Else' part of an 'If-Then-Else' block?
A. This is not allowed in Scratch.
B. The inner 'If-Then' block will only be checked if the outer 'If-Then-Else' condition is false.
C. The inner 'If-Then' block will always execute, regardless of the outer condition.
D. The outer 'If-Then-Else' block will become an 'If-Then' block.
Click to see Answers
1. C
2. B
3. C
4. B
5. B
6. C
7. B
Join the discussion
Please log in to post your answer.
Log InEarn 2 Points for answering. If your answer is selected as the best, you'll get +20 Points! 🚀