Programming Fundamentals
It is like…
A variable is like a labelled container
A typed variable is like a labelled storage container
Quick check · tap an answer to continue
Lesson notes
Key points
- Picture a market trader's shelf where every container has a label and is made for one kind of goods only.
- The label is the variable name, the contents are its value, and the container's shape is its data type.
- It breaks with references: in Python, two labels can point to the same object, so changing one changes both.
Definitions
- Reference
- A variable holding the address of an object, so several names can share and mutate one object
Takeaway: Name, value, type: and sometimes two names share one object.
Quick check: In the container analogy, what does the container's shape represent?
- The variable name
- The data type
- The stored value
The shape limits what fits inside, just as a type limits what values are allowed.
The shelfThe mappingWhere it breaks
Lessons like this, for your syllabus.
Short narrated study videos written for your course, level and exam. Free to start.
Get lessons for your own syllabus