Module 1
Changing variables
Variables can be updated.
A variable can change
The word variable comes from 'vary', meaning it can change. You can assign a new value to a variable at any time. The old value is replaced.
PythonThe variable is updated.
temperature = 30 print(temperature) temperature = 35 print(temperature)
→ 30
35
The first print shows 30. Then we store 35 in the same variable. The second print shows 35. The old value is gone, replaced by the new one.
Your task
Change a variable
- The variable score is set to 10. Change it to 20, then print it.
Remember
A variable holds one value at a time. Assigning a new value replaces the old one.