CBSE Class 9 Computer Applications
Question 35 of 35
Scratch Programming I — Question 12
Back to all questions 12
Question Question 12
What is an if-statement ? Give two examples.
The if block from Controls category is used when we have to take an action depending upon a certain condition. It allows a program to execute certain actions only if a specific condition is true. If the condition is false, the actions within the if-statement are skipped.
Consider the following examples:
1. If we want our sprite to move to the center of the stage when it touches the edge of stage, we can use the given script:
if touching edge then
go to x : 0 y : 0
2. If we want our sprite to say "You win" when it touches another sprite (ball), we can use the given script:
if touching ball then
say "You win"