Kids Coding

Boxes (Variables)

A variable is a named box. Put a name or a number in it. Use it later.

KidsBasicBoxes (Variables)

A box with a name

A variable is a named box. You put a value in it. Later you use the name instead of typing the value again.

Store a name

name = "Sam"
print(name)
print("Hi, " + name)

The name goes on the left of =, the value on the right. 5 = age is backwards and Python will complain. Always age = 5.

How to name a box

  • Start with a letter.
  • Use lowercase and underscores: high_score.
  • Do not use spaces. high score will fail.
  • Do not use a name Python already needs, like print.

You can change what is in the box

A new = puts a new value in. The old value is gone.

Change a score

score = 0
print("Start:", score)
score = 10
print("Now:", score)

Real life

A nickname on a game scoreboard.

You store the name once. Every message can reuse the box.

Scoreboard name

player = "FoxKid"
score = 12
print(player + " has " + str(score) + " points")
score = score + 3
print(player + " now has " + str(score))

Change one word. Run it. That is how this idea shows up outside the lesson.

Try it

Exercise 1: Make a variable pet with an animal name. Print My pet is and the name.

Show solution
pet = "fox"
print("My pet is " + pet)

FAQ: Boxes (Variables)

Common questions about this page.

What is StudyGrid Kids?

StudyGrid Kids is a free coding path for children: Basic, Intermediate, and Advanced. Lessons use Python in the browser. No account and no install.

Should I run boxes (variables) examples locally for better learning?

Yes. Use the browser editor on StudyGrid for a quick check, then Download the example and run it on your computer. Local runs show real errors and the real toolchain, which is one of the fastest ways to learn boxes (variables) in this Kids Coding Python lesson (Boxes (Variables)).

Which kids level should we start with?

Start at Basic if the child has never written code. Choose Intermediate if they can print, use variables, and write a simple if. Choose Advanced if they already use loops and lists.

Do kids need an account or an app?

No. Kids pages are public. Code runs in the Try Python editor at /try. We do not ask children for a name or an email.

What language do kids learn?

Python, with a first HTML page in Intermediate and Advanced. After Advanced, the main Python tutorial is the next step.

Is the kids coding track free?

Yes. The Kids home, the three levels, and the Python editor on StudyGrid (studygrid.in) are free.