PYTHON_101 | VARIABLES
SMARS Learning Platform
31% Complete
PYTHON_101 | VARIABLES
a = 1
When we want to store a value we need to use a variable. In the example we looked at above we stored the number 1
in the variable a
.
When we think about variables, we can imagine they are like little boxes that store things, and we give those boxes names so that it makes referring to them easier. We can put things into the boxes, look what’s in them or compare what’s in them with another box.
We could just give our variables a numbered label but that would make it difficult to remember what is in each one. By naming our variables we can easily understand what we expect the variable to contain. For example if we want to storge the age of a person we could use a variable named age
.
age = 21
In Python variables don’t actually store the value, they just point to the thing that does.