Page 94 - TP_Play_V2.1_class5
P. 94
Here the condition is the availability of mango:
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.
92 Play (Ver. 2.1)-V

