
What Is a Variable: A Box or a Label?
Series: Programming Concepts in Plain English Part 1: Learning Programming Alone: From Panic Loops to Mental Pictures When I first started learning programming, someone asked me a question I never forgot: "What is the difference between a variable and a string?" At that time I didn't even fully understand what a variable was. But the question was really testing whether I understood the concept of a variable. That moment forced me to rethink everything I assumed. Most beginners imagine a variable as a box that stores data. In many programming languages, that idea works well enough. But in languages like Python, a variable behaves differently. It is better understood as a label attached to an object. Let's explore both ideas. The Box Model (common beginner model) Imagine you work in a warehouse and must store different products. Each product is placed in a carton. The carton holds the product. The product inside can change without replacing the carton itself. This is the "box" idea: The
Continue reading on Dev.to Tutorial
Opens in a new tab



