Page 85 - IT_V5.0_Class8
P. 85

Example 15: When the green flag is clicked, the sprite sets its colour to a randomly picked value
                 between 1 and 10. It then thinks “Hmm” for a duration between 60>50 seconds, and finally says
                 “Hello!” for a duration 12-4=8 seconds.

























                 Variables Blocks

                 These blocks in Scratch are used to store and manipulate data values. These blocks can hold
                 variables and lists. There are 5 Variables blocks and 11 list blocks in Scratch 3.0.
                 Variables can hold numbers or strings and can be used to keep track of information that changes
                 during the execution of a program.

                  Block                             Explanation

                                                    Creates a new variable.

                                                    Represents the value of the variable named “my variable.”
                                                    The name can be changed to anything meaningful.


                                                    Sets the value of the variable to a specified value.



                                                    Changes the value of the variable by a specified value.



                                                    Displays the variable’s value on the stage.


                                                    Hides the variable’s value from the stage.


                                                    This block creates a new list variable that can be used to
                                                    store and manipulate multiple items.

                 Example 16: Make a script to take two numbers from user and display their sum in the speech
                 bubble.
                 Follow the given steps:
                 Step 1:  Click on the Variables category.



                                                                                              Learning Scratch   83
   80   81   82   83   84   85   86   87   88   89   90