Introduction to variables

Variables are an important programming concept. In programming, a variable is a placeholder for some value.

To create variables, you should click on the Create button at the top left corner of the screen.

This will open the Data types window. Here, you will see the various data types to use.

Select the data type you need and click the Select button.

For our example, we are going to create a variable called Name of type String and assign it the value "John". So, choose String from the list and click Select. You are going to see a block like this:

Now, input Name in the text box.

To assign a value to it, you need to use a setter block. Setter blocks are commands that set a value to a variable. To add a setter block, right-click on the block and select Set “Name” variable:

This will add the setter block.  You can assign the value “John” to the setter block.

Now, we are going to add a getter block for Name variable to be able to get the value John. Getter blocks are expressions that 'get' or contain a current value. Right-click on the String block and select Get “Name” variable:

This is how the getter block looks like:

So, if we want the program to display “John”, this is the code we will write: