Skip to main content

Variables

A variable is the address of a temporary value in the computer memory.

Every time we declare a variable with a value, it gets stored in a certain address in RAM. And the variable name is the usual way to refer to the stored value.

Variable declaration#

For example, imagine you have this calculation 1+1+1 which you use in multiple places in your code:

When you have to update the calculation, for example, changing it to 123, you will need to update the calculation in all instances in the code. Instead, you can assign the original calculation to a variable, and then simply update the calculation just once in the variable:

Example:

<var_name> = <value>;
Var_name = should not start with a number or special char.Value    = can be a constant or an expression or another variable.