Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 64 - 2617_JSSPS_C-4
P. 64

    Creating Variables in Scratch

                  To create variables in Scratch, follow the given steps:

                  Click on For this sprite only if you want this variable to appear for the selected sprite only.
                  Here, we have added the variable fruit. It will be available for all the sprites.

                      2   Click on Make a                                                     Type a variable name
                          Variable block.
                                                                                              in the New variable      3
                                                                                              name box.

                                                                                                        Click on the
                                                                                                        radio button
                                                                                                        of either of    4
                                                                                                        the options.

                    1   Click on Variables
                        block category.

                                                                          5
                                                                              Click on Ok button.

                  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:

                                                                                Factbot

                                                                          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.

                            Premium Edition-IV
                     62

| 59 60 61 62 63 64 65 66 67 68 69 |