Page 59 - Touchcode_C6_Flipbook
P. 59

Step 10:  Change the comparison operator to '>=' and '<=', and the value to '5' and '15'














                  Step 11:  When you click on the 'on start' block, the program runs and displays green
                            colour as an output. (Explanation: As the value of 'Height' is '10' in the 'set Height'
                            block, now the value is greater than 5 and less than 15, so the 'If' block will run

                            and  'Green' color will get displayed as an output.)













                  Step 12: Change the value of 'Height' to  '2':













                  When you click on 'on start' block, the program runs and displays yellow colour as an
                  output. (As the value is '2' in the 'set Height' block, now the value is less than 5, so the
                  'IF' condition is not satisfied, then the 'else' block will run and the 'Yellow' color will get
                  displayed as an output.)








                   Well done, by now you have learned to create dynamic background!


                 NESTED CONDITIONAL STATEMENTS

                 In some cases, a single if-else statement is not enough to handle complex conditions.
                 When an if-else statement contains another if-else statement inside it (either within the if

                 block or the else block), it is called a nested conditional statement or nested if-else.

                                                                                     Control with Conditionals   57
   54   55   56   57   58   59   60   61   62   63   64