Page 108 - 2422_C5_Flipbook
P. 108

The variable appears in the list of Variables blocks. Observe
                           that the variable name fruit appears in all the blocks.




                               Now create the following script:


                                                                    Tech Fact

                                                            Every time you type a name
                                                           or number, the previous value
                                                            in the variable gets deleted
                                                            and the new value is stored.




                  The sprite will ask you to type your favourite fruit. When you press the Enter key, the name of

                  the fruit appears in the speech bubble of the penguin. The name of the fruit then appears in the
                  answer as well as in the variable name on the stage.






















                  This variable 'fruit' is a string variable as we are saving names in the variable. If you save
                  numbers in a variable, say, 'Mobile', it will be a numeric variable.


                         USE OF CONDITIONAL CONTROL BLOCKS


                  Many times, you have to do a task which is dependent on some conditions. For example, you

                  have to make mango shake. There are two conditions:
                  a.   Go to the refrigerator and check if there are mangoes. If mangoes are there, then you will

                     make mango shake.
                  b.   If the mangoes are not there, you will make cold coffee.

                     Here the condition is the availability of mangoes:



                  106   Premium Edition-V
   103   104   105   106   107   108   109   110   111   112   113