Variable: a label attached to a piece of data.
Creating a variable
The assignment operator
= is used to create a variable; in other words, to attach a label to a value.
a = 2 name = "Jason Bourne" sum = a + 8
Variables can be re-assigned.
a = 2 print(a) a = 3 print(a) a = a + 10 print(a)
2 3 13
A variable name:
- must start with a letter or the underscore character
- can contain only letters, numbers and underscores (
- cannot start with a number
Variable names are case sensitive:
NAME are three separate variables.