Back to Blog
Chief Idiot2 min read

Python 1.2: The Boxes (Variables)

How to remember things without using your brain. Introduction to Variables, Strings, and Lists.

Storing Stuff (So You Can Forget It)

Computers are great because they never forget. Humans are terrible because we forget why we walked into the kitchen.

In Python, when you want the computer to remember something, you put it in a Variable.

Think of a variable as a Cardboard Box. You write a name on the box with a sharpie, and you throw something inside.

Python Variables Boxes

The Three Main Boxes

1. The Number Box (Integer/Float)

Math stuff.

age = 30
bank_account = -500.25

2. The Text Box (String)

Anything with quotes around it.

name = "Chief Idiot"
quote = "I code therefore I smash keyboard."

3. The Junk Drawer (List)

The best box. You can throw anything in here. Numbers, strings, other lists. It doesn't care.

# A list of random stuff
my_drawer = ["Keys", "Wallet", 42, "Half-eaten sandwich"]

The "Idiot" Rule for Naming

You can name your boxes whatever you want.

Bad Name:

x = "John"  # Who is x? A spy?

Good Name:

user_name = "John" # Ah, it's a user.

Idiot Name (Also Acceptable):

that_guy_from_marketing = "John"

Trying It Out

Go ahead. Make a box. Put something in it.

box = "cat"
print(box)

You just did memory management. You are a genius.

Share this article