Elena' s AI Blog

Magic Boxes: Remembering Things with Variables

05 Jan 2026 / 2 minutes to read

Elena Daehnhardt


Lesson 2 of 10 20%


TL;DR: A variable is like a box with a label. You can put things in it (like `score = 10`) and find them again later using the label.

The Problem with Forgetting

Imagine if you had to re-introduce yourself every time you spoke to your best friend. “Hello, my name is Sam.” “Hello, my name is Sam.” “Hello, my name is Sam.”

That would be exhausting! Computers are the same. If we want them to remember something—like your name, your age, or your score in a game—we need to give them a place to put it.

Enter the Variable (The Magic Box)

In Python, a variable is just a box with a name on it.

name = "Sam"
score = 100

Here is what happened:

  1. We created a box label “name” and put the text “Sam” inside.
  2. We created a box label “score” and put the number 100 inside.

Now, whenever you type name, the computer looks in the box and sees “Sam”.

print(name)

Output:

Sam

Changing the Contents

The best thing about variables is that they can change (that’s why they are called vari-ables!).

Imagine you are playing a game and you get a bonus point.

score = 100
print(score)  # Computer says: 100

score = score + 1
print(score)  # Computer says: 101

You took the value out of the box (100), added 1 to it (101), and put it back in the box.

Rules for Naming Boxes

You can name your variables anything you want, but there are a few rules:

  • No spaces: Use player_score, not player score.
  • Start with a letter: score1 is okay, 1score is not.
  • Be clear: x is a bad name. player_name is a great name.

Try It Yourself

Write a program that:

  1. Creates a variable called wizard_name.
  2. Creates a variable called magic_power.
  3. Prints them both out.
wizard_name = "Merlin"
magic_power = 50
print(wizard_name)
print("Power Level:", magic_power)

In the next lesson, we will make the magic boxes interactive!


This post is part of the Python Basics for Kids series, based on “Python for Kids from 8 to 88”.

desktop bg dark

About Elena

Elena, a PhD in Computer Science, simplifies AI concepts and helps you use machine learning.

Citation
Elena Daehnhardt. (2026) 'Magic Boxes: Remembering Things with Variables', daehnhardt.com, 05 January 2026. Available at: https://daehnhardt.com/courses/book0/02-magic-boxes/
Course Library