Variables in Python
In this lecture you will learn about variables, by the end of the lecture you will have good understanding the of following:
- How to declare a variable in Python
- Variables naming rules (conventions)
- How to assign a value to a variable
What is a variable ?
A variable simply is name (reference) to a memory location in the computer. A variable holds a value and this value may change. So you can imagine that a variable is a BOX that we can put a stuff in.
In reality, Python does not have variables. Instead it creates object references to refer to data objects. Data objects hold our data like numbers, words, group of values.
In the following lectures and throughout the course, when we say variable or object reference, we mean the same thing.
In this lecture we will talk about object references that refer to numbers (whole numbers without fractions).
How to create an object reference in Python:
The syntax is simple:
object reference (variable) = value