Variables

We use variables to store data.
A variable has a name and a type.

Let's say we are calculating the total amount that we spent on some items.
We can use 3 variables:

  • amount of type Integer
  • price of type Real
  • total of type Real

Before we use a variable, we must declare it.
Click the line and select the Declare item.
Then:

  • enter amount for variable name
  • select Integer for its type
  • enter 3 for its initial value

Do the same for price, set its type to Real and value to 1.5

Now we can finally calculate the total amount.
Declare total, set its type to Real and value to amount * price

This last part is very important, you can use variable name as a value!
Lastly, add total block to print the value of total.

3 / 6