![header-lesson-01](assets/header-lesson-01.png)

# Variables

## What is a variable?

In computer science, a **variable** is like a container that holds information. This information can be a number, a word, or something else. For example, if you’re writing a game, you might have a variable to keep track of the player’s score. Every time the player scores a point, the computer changes the number in that variable. Variables help computers remember things while running a program, making it possible to do all kinds of tasks, like simple math, keeping track of a game’s progress, or storing sensor data.

To create a variable, select "Variables" in the Toolbox.

![makecode-variables-01](assets/makecode-variables-01.png)

Click on "Make a Variable".

![makecode-variables-02](assets/makecode-variables-02.png)

A window will appear with a text box and an "Ok" button.

![makecode-variables-03](assets/makecode-variables-03.png)

Enter your "name" in the "New variable name" box, and press "Ok".

![makecode-variables-04](assets/makecode-variables-04.png)

A new set of blocks related to the variable you created will appear.

![makecode-variables-05](assets/makecode-variables-05.png)

Select the `set` block.

![makecode-variables-06](assets/makecode-variables-06.png)

Place the `set` box in the `forever` block. 

![makecode-variables-07](assets/makecode-variables-07.png)

Move the `forever` block.

![makecode-variables-08](assets/makecode-variables-08.png)

It is now visible without obstruction.

![makecode-variables-09](assets/makecode-variables-09.png)

You now need to add a string to the oval with a `0`. Select "Advanced" in the Toolbox.

![makecode-variables-10](assets/makecode-variables-10.png)

Next, click on "Text" to see the blocks that are used for strings.

![makecode-variables-11](assets/makecode-variables-11.png)

Select the empty string  `" "` block.

![makecode-variables-12](assets/makecode-variables-12.png)

Place the empty string `" "` block in the oval in the `set` block. Change the string to your name.

![makecode-variables-13](assets/makecode-variables-13.png)

Now click on the "Basic" drawer of the Toolbox.

![makecode-variables-14](assets/makecode-variables-14.png)

Select the `show string` block.

![makecode-variables-15](assets/makecode-variables-15.png)

Drag the `show string` block into the `forever` block.

![makecode-variables-18](assets/makecode-variables-18.png)

Click on the "Variables" drawer of the Toolbox.

![makecode-variables-19](assets/makecode-variables-19.png)

Select the variable `name`

![makecode-variables-20](assets/makecode-variables-20.png)

Place the variable block `name` in the `show string` block.

![makecode-variables-21](assets/makecode-variables-21.png)

The code is now ready to be flashed on the micro:bit.
