How do Computers Remember Things?

Welcome to the land of Python (used for development of programs, AI, VMs, etc.), where computers aren’t just machines; they’re storytellers, too.
They remember names, ages, favorite colors, and even your snack list.
But here’s the trick: computers only remember things through variables and data structures: tiny containers that hold information like memory jars.
Let’s peek inside those jars and see how they work.
📦 Variables: Named Boxes
A variable is like a box with a label. You put something inside, give it a name, and later, you can open it up again.
Example:
name = "Ahmad"
age = 8
Now you’ve created two boxes:
name → "Ahmad"
age → 8
Python will remember what you put inside each one.
🧠 Rules for Naming Variables (No Cheating!)
You can’t just scribble any name on your box. Python has some strict rules:
You can use:
- Letters (A–Z, a–z)
- Numbers (0–9)
- Underscores (_)
You can’t:
- Start with a number (
2name) - Use spaces (
my name) - Use special characters like
@or$ - Steal Python’s own words like
if,for, orprint
Good names:
name = "Aisha"
my_name = "Mariam"
age2 = 9
Types of Variables: What is Inside the Box?
Different boxes hold different kinds of stuff. Python calls these data types.
1. 🧮 Integer (int)
Whole numbers: no dots, no decimals.
age = 8
score = 100
2. 🌊 Float
Numbers with a dot.
height = 4.5
price = 9.99
3. 💬 String (str)
Words or text inside double quotes.
name = "Zain"
city = "Karachi"
4. 🔘 Boolean (bool)
Only two choices: True or False.
is_smart = True
is_sleeping = False
5. 🔤 Character (char)
Just a single letter, symbol, or number inside single quotes.
grade = 'A'
symbol = '$'
Python doesn’t have a separate type called “char”. It’s just a string with one letter.
🧺 Lists: Baskets of Many Things
A list is a flexible container that can hold many boxes, numbers, words, or any other items.
fruits = ["Apple", "Banana", "Mango"]
You can grab one item using its number (called an index):
print(fruits[0]) # Apple
Add a new item:
fruits.append("Orange")
Change something:
fruits[1] = "Grapes"
Now your basket looks like:
["Apple", "Grapes", "Mango", "Orange"]
Lists are changeable like a backpack, you can keep packing new things into.
🪣 Tuples – Locked Baskets
A tuple looks like a list, but once you close the lid, it’s sealed forever.
colors = ("Red", "Green", "Blue")
Try changing it:
colors[0] = "Yellow"
Python will throw a fit:
TypeError: 'tuple' object does not support item assignment
Tuples are great for things that never change, like days of the week:
days = ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
🧱 Dictionaries: Smartest of All
Now we get fancy.
A dictionary is like a magic notebook that stores information in pairs: one thing to ask with (the key), and one thing to get back (the value).
Example:
student = {
"name": "Fatimah",
"age": 8,
"grade": "A"
}
Think of it like this:
"key" → "value"
"name" → "Fatimah"
"age" → 8
"grade" → "A"
You can look up any value by its key:
print(student["name"])
Output:
Fatimah
You can even add or change things:
student["hobby"] = "Coding"
student["grade"] = "A+"
Now your dictionary is:
{"name": "Fatimah", "age": 8, "grade": "A+", "hobby": "Coding"}
Dictionaries are like your brain: they connect ideas with information.
🎯 Sets: No-Repeat Club
A set is like a box that refuses to hold duplicates.
If you put the same thing twice, it just ignores it.
Example:
numbers = {1, 2, 3, 3, 2, 1}
print(numbers)
Output:
{1, 2, 3}
Sets are useful when you just want to know what exists, not how many times.
You can add things:
numbers.add(4)
And remove things:
numbers.remove(2)
They’re great for finding unique items or comparing lists.
Summary Table
| Type | What It Stores | Example | Can Change? |
|---|---|---|---|
| int | Whole numbers | age = 8 | ✅ |
| float | Decimal numbers | height = 4.5 | ✅ |
| string | Text | name = "Kanwal | ✅ |
| boolean | True/False | is_happy = True | ✅ |
| character | One symbol or letter | grade = 'A' | ✅ |
| list | A changeable group | ["a", "b", "c"] | ✅ |
| tuple | A locked group | ("a", "b", "c") | ❌ |
| dictionary | Key–value pairs | {"name": "Ali"} | ✅ |
| set | Unique values only | {1, 2, 3} | ✅ |
Practice Time!
Try this small program:
name = "Aminah"
age = 8
fruits = ["Apple", "Banana", "Cherry"]
colors = ("Red", "Green", "Blue")
student = {"name": "Aminah", "grade": "A", "hobby": "Coding"}
numbers = {1, 2, 3, 3, 2, 1}
print("Hi, my name is", name)
print("I am", age, "years old.")
print("I like", fruits[2])
print("My favorite color is", colors[1])
print("My hobby is", student["hobby"])
print("Unique numbers are:", numbers)
Output:
Hi, my name is Aminah
I am 8 years old.
I like Cherry
My favorite color is Green
My hobby is Coding
Unique numbers are: {1, 2, 3}
Golden Spell of Memory
Variables are boxes.
Lists are flexible baskets.
Tuples are sealed baskets.
Dictionaries are notebooks with labels.
Sets are picky boxes that hate repeats.Together, they form the memory system of Python
The way a computer learns to think, organize, and remember.
Visit my GitHub to learn more!
Excellent Information. I am a python beginner and this article helped me alot. The easy wording and explanation like the comparison of kiss with a basket and dictionariws with a wall was unique. However, if possible, I really want you to explain the kinds of loop in your next blog.
Glad to help you out. Sure, I will upload the info regarding loops as well as functions in my next vlog. Just keep on checking in and you might get a surprise in the next 3-5 days.
This article is such an amazing and easy way to understand Python Variables ! The examples are really clear and creative – they made learning feel fun and simple. I especially love how the concept of Variables is explained like memory jars . Keep up the wonderful work! 👏🏻👏🏻
You’re welcome. Am really glad to know that my article has helped you.
An infornarive article indeed!!
Looking for to more of your blogs👍
Glad to help
I am lucky that I found this website, precisely the right info that I was looking for! .
Am glad to know that my blog has helped you! Just keep checking in and sign up to my newsletter as a part 2 of this blog is coming soon.