What a Python Variable Is, for Kids

Boxes that hold things — and how to look inside them.

  • Lesson 1 of 5
  • Free
  • Ages 10+
  • 4 hands-on levels
Try this lesson interactivelyReal Python, running in your browser.

The dragon explains

The dragon remembers

  1. The dragon: I can say anything you tell me. But I can also REMEMBER things — and that changes everything.

  2. The dragon: This makes a box called dragon_name and puts Ember inside it. The = means 'put this in there'.

    example.pyPython 3
    dragon_name = "Ember"
  3. The dragon: Nothing gets said yet. The box is just sitting there, holding the name, waiting.

    example.pyPython 3
    dragon_name = "Ember"
  4. The dragon: Now watch. Put the BOX NAME inside print — no quotes — and I say what is inside it.

    example.pyPython 3
    dragon_name = "Ember"print(dragon_name)
    OutputEmber
  5. The dragon: Careful though. With quotes, you get the box's name instead of what is in it.

    example.pyPython 3
    dragon_name = "Ember"print("dragon_name")
    Outputdragon_name
  6. The dragon: Quotes mean 'say these exact letters'. No quotes means 'look inside the box'. Same rule you already know.

    example.pyPython 3
    print(dragon_name)print("dragon_name")
    OutputEmber dragon_name
  7. The dragon: And boxes hold numbers too — those never need quotes at all.

    example.pyPython 3
    gold_coins = 250print(gold_coins)
    Output250

Quick check

Check your understanding

Say your answer out loud before reading the marked one. Every wrong option is a mistake real beginners make.

  1. Question 1 of 2

    What will I say here?

    question.pyPython 3
    pet_name = "Fluffy"print(pet_name)
    • FluffyCorrect
    • pet_name
    • pet_name = "Fluffy"

    Why: print(pet_name) with no quotes means 'look in the box and say what's inside', so I say Fluffy. The box's name is just a label; it's never what I say.

  2. Question 2 of 2

    And this one — spot the difference.

    question.pyPython 3
    pet_name = "Fluffy"print("pet_name")
    • pet_nameCorrect
    • Fluffy
    • Nothing — that's an error

    Why: With quotes, I read the letters exactly: pet_name. It's the same quotes rule from before — quotes mean the literal thing, no quotes means look it up.

In the game

What you'll practice

Four levels in the game: one guided first try with the shape of the answer already there, then three to solve on your own.

  1. 1

    GuidedYour first try

    The dragon has never had a name. Make a box called dragon_name, put a name inside it, then ask the dragon to say what it remembers.

  2. +3

    PracticeThree more, on your own

Try it yourself — in real Python.

This lesson is part of a free topic: every lesson in it is free, and no card is needed.

Start this lesson for real

Stuck three times? The game offers the answer — unasked.