Using variables to store results
Variables are used to store the results of calculations in order for them to be used later.
# times table x = 2 y = 6 result = x * y x = 3 print x * y print result
Run the code. Did you expect the two values which were printed to be the same? Why are they different? The answer is that result stores the answer and not the calculation. As such result stores 12 (2 * 6) so when we change x to 3 it has no effect on result.
x = 10 y = 20 result = x + y print result
Copy the above code and change line 1 and 2 to make the code print out the value 18.
Output: (clear)











