Page 47 - Code & Click - 6
P. 47
Experiential Learning
Lab Activity 2
Let us create a variable called Number, set its initial value to 10, and hide the variable. Each time
the space key is pressed, the value of the variable is increased by 5, and the sprite displays the new
value of the variable.
1. Create a new project.
2. In the Variables blocks palette, create a variable – Number.
3. In the Scripts area, create the stack of blocks as shown in the image.
4. Click the Go button to execute the project.
5. Press the spacebar key and observe the result.
6. Click the Stop button to end the project.
The sample images for the project are given below.
Changing Appearance of the Variable
A variable can be displayed in three forms. These are:
• Normal Readout: The Normal Readout option displays the name of the
variable and its value on the Stage.
• Large Readout: The Large Readout option displays only the value of
the variable in a larger size than normal readout.
• Slider: The Slider option displays the name and value of the variable,
along with a slider to change the value of the variable. The range of
value for the slider is from 1 to 100.
2 2
To change the appearance of a variable:
3 1. Select the variable to display on the Stage.
2. Right-click the display of the variable on the Stage.
3. Select the appearance option for the variable from the list.
Renaming a Variable 1
A variable can be renamed to reflect the type of value
it stores and displays. 2
45