Page 79 - Trackpad_ipro 4.1_Class6
P. 79
Change pen color by 10 block changes the pen colour, saturation, brightness and
transparency. Click on the first text box to select and change the pen effects. Click on the
second text box to give a value by which the effect will change.
set pen color to 50 block will set the pen colour, saturation, brightness and transparency
to the given value.
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.
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 changes. For example, in the move block, the variable has a value 10 by default. You can
modify this value according to your script.
Types of Variables
Variables can store numbers as well as letters. A variable that stores numbers is called a numeric
variable. These numbers are used in calculations. Examples are 48, -986, 12345, etc.
A variable that stores letters in the form of strings or characters is called string variable. A string
variable can store names, words, sentences, numbers, and enclosed in quotation marks. For
example, “Kavita”, “1 am 12 years old”, “12345”. These variables are not used in calculations.
Creating Variables in Scratch
To create variables in Scratch, follow the given steps:
Step 1 Click on Variables block category. A set of blocks appears in the block palette.
Step 2 Click on Make a Variable block. A New Variable dialog box appears. Type a variable
name in the New variable name box.
Step 3 Click on the radio button of either of the options. Click on For all sprites if you want this
variable to appear for all the sprites.
Or
Click on For this sprite only if you want this variable to appear all the sprites only. Here
we have added the variable fruit. It will be available for all the sprites.
Scratch Programming—Game Creation 77

