Page 105 - TP_Pluse_V2.2_Class_5
P. 105
We can also write this in two ways:
1. if 2. if
mango is available mango is available
then then
make the mango shake make the mango shake
else
make cold coffee
In such situations, we use conditional blocks. Scratch has two conditional blocks. They are:
1. If...then block: In this block if the condition is true, the blocks inside then or only inside
conditional block will run. If the condition is false, the blocks inside conditional block will not
run. Only the blocks outside the conditional block will run.
2. If...then...else block: In this block if the condition is true, the blocks inside then condition will
run. If the condition is false, the blocks inside else condition will run.
Try out the following examples:
Suppose, we want to check whether a person is a senior citizen or not. The code for this can
be defined using if...then as:
But this code does not give an output if the age of the person is less
than or equal to 60 years. For such situations, when two different
outputs are to be specified for two conditions, we use the if…then…
else block. In this block, if the condition is true, the code inside the
first C (shape) will be activated. If the condition is false, the code
inside the second C (shape) will be activated.
USE OF LOOPS BLOCKS
All the programs or projects developed till now run only once. If you want to run a set of
statements more than once, you will either run the code again or write the script again. In
Scratch, we can save our time and effort by repeating the code without writing the program
again or writing the script again. The automatic running of a set of instructions more than
once is called looping. The blocks for looping are given in the Control category.
The repeat block is used to run a set of instructions for a specified number
of times.
Conditional Blocks in Scratch 103

