top of page

Variables Blocks

What is variable?

Variable is a reserved memory location to store values. Memory location has a label and a value. The value can be dynamic and can be changed programmatically.

Variables can only hold one value at a time, unlike lists. These values can be either numbers or strings.

How to create your own variable?

The clickable button “make variable” in variables category, allows the user to create new variable.

Scratch does not allow variables to be created by a script as it runs. Instead, variables are created with the "Make a Variable" button

What is the difference between “for all sprite”, “for this sprite only” and “cloud variable”?

When you create your own variable, you will get two options of radio buttons and one checkbox option.

For all sprite:

This is a global variable. Global variables can be read and changed by any sprite, or the Stage. All variables are stored in RAM, and default to the values in the file it originates from. When creating a variable, by default ‘for all sprite is applicable.

For this sprite only:

This is a local variable. Local variable can be created by selecting “for this sprite only” option. These variables can only be changed by their owner but can be read by other sprites. The Stage cannot have local variables.

Cloud variable:

Cloud variables are variables that are stored on the cloud server. In Scratch 3.0, cloud variables only support numerical data, and all are limited to 256 characters, you are allowed 10 cloud variables in a single project.

How to rename the variable?

You can rename the variable in two ways. One you can right click on the variable and select the option “rename”.

Another way – you can programmatically change using any of the 4 blocks.

How to delete the variable?

You can delete in two ways. One you can right click on the variable and delete.

Another way – Use any of the 4 blocks to delete.

How to show the variable on the stage?

There are two ways to show. One is checking the check box next to the variable

Another one – use the block “show variable”

How to hide the variable from the stage?

There are two ways to hide the variable from the stage. One is unchecking the checkbox next to the variable.

Another one – use the “hide variable” block

How to use the variable with other blocks?

The variable we create is a reporting block and can be used with other blocks like operators.

How to use “set variable to ()” block?

This block allows to initiate the value for the variable.

How to use “change variable by ()” block?

This block allows to change the variable by given value

Exercise 12

1. In nature what dynamically changes? Example air temperature, wind speed. Explain.

2. In nature what doesn’t change for lifetime? Example Speed of the earth rotation. Explain?

28 views0 comments

Recent Posts

See All


bottom of page