Page 110 - TP_Plus_v4_Class4
P. 110
VARIABLES
A program is a group of commands and instructions that tell the computer to carry out a
task. In scratch, a program is called a script. A script is made up of a number of blocks. So, the
blocks are the commands or instructions that we give to the sprite to perform a task. In Scratch
you can make programs to create games, stories and animations.
All the numbers, text, date or pictures that we use in a program are called data. We store
this data in the computer memory so that we can get information from it later. This data is
stored in variables. It is called variable because it does not have a fixed value, its value varies
or changes. For example, in the move block, the variable has a value 10 by default. You can
modify this value according to your script. Variables can store numbers as well as letters.
Creating Variables in Scratch
To create variables in Scratch, follow the given steps:
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.
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.
The variable appears in the
list of Variables blocks. ask Which is your favourite fruit? and wait
Observe that the variable set fruit to answer
name fruit appears in all the say answer for 4 seconds
blocks.
Now create the following Factbot
script:
Every time you type a name or number,
the previous value in the variable gets
deleted and the new value is stored.
108 PLUS (Ver. 4.0)-V

