Variables
Declaring variables
Section titled “Declaring variables”Declare a variable with the equals symbol =.
| Calculation | Result |
|---|---|
discount = 10% | 10% |
cost = 200€ | €200 |
cost - discount | €180 |
A variable can be a single word or an entire phrase (i.e. red apples = 10).
Redefining variables
Section titled “Redefining variables”A variable can be redefined by giving it a new value.
The most recently defined value will be used on subsequent lines.
| Calculation | Result |
|---|---|
amount = 50€ | €50 |
amount x 2 | €100 |
amount = 20€ | €20 |
amount x 2 | €40 |
Variables named like units
Section titled “Variables named like units”A variable can have the same name as a unit, like l (liters). On the lines
below it, the name means your variable:
| Calculation | Result |
|---|---|
l = 2 | 2 |
l * 3 | 6 |