S15 Resource sheet 1

  • A variable in programming is a slot in the computer’s memory where you can store a value.

  • This value could be a number or a string of letters.

  • Think of it as a box where you can put in values and change them when you need to.

  • The program will use the latest value you have “put in the box”.

You can create a variable in Python by giving it a name and a starting value.

e.g.

cat = 1

number = 1

dog = 15

my_variable = 3

distance = 66

You can also give variables a ‘string’ value, but you will not need that in this session.

e.g.

name = ‘Thor’

Have a go at making a few variables of your own:

Last updated