Page 77 - IT_V5.0_Class7
P. 77

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 13: 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.
                 Step 2:  Click on the Make a Variable button. The New Variable dialog box appears.
                 Step 3:  Type name of the variable in the New variable name text box.

                 Step 4:  Click on the OK button.
                 Step 5:  Similarly, create another variable named Num2.





                                                       2


                                                                                                      5









                       1

                                                                3             4




                                                                                              Learning Scratch   75
   72   73   74   75   76   77   78   79   80   81   82