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 |