Page 73 - modular4.0
P. 73
Chapter Profile
Creating Variables in Scratch
To create variables in Scratch, follow the given steps:
2 Click on Make 3 Type a
variable name in the
a Variable block. New variable name box.
A New Variable
dialog box appears.
1 Click on Variables
block category. A set
of blocks appears in
the block palette.
5 Click on OK
4 Click on For all sprites if you want this button.
variable to appear for all the sprites.
Here we have added the variable fruit. Observe that the variable name fruit
appears in all the variable blocks.
Now create the following script:
Clickipedia
Every time you type a name or number, the previous value in the variable gets deleted and
the new value is stored.
Click on the script. The sprite will ask you to type your favourite fruit name. After giving
your favourite fruit name press the Enter key, the name of the fruit appears in the speech
bubble of the penguin. The name of the fruit appears in the answer as well as in the variable
name on the stage.
Creating a Game in Scratch 71

