Is a coding variable the same as algebra’s x?
By the end of this lesson
Trace a three-line Python script that sets a variable, changes it, and prints it — and say it is the same box as algebra’s x.
Remember
- A variable is a named box. score = 5 puts 5 in the box called score.
- The = in Python is “put this into that box”, not the algebra balance (though we still check truth later).
- print(score) shows what is in the box. print("score") shows the word score.
- You can update: score = score + 1.
- Same idea as algebra’s x. Different spelling.
Worked examples
Cover the answer. Try the steps on paper, then open them.
Example 1 — Trace
name = "Asha" print(name)
- Box name now holds Asha
- print shows Asha, not the word name
Answer: Asha
Check: No quotes around name in print — we want the box, not the label.
Example 2 — Update
score = 4 score = score + 1 print(score)
- score starts at 4
- score + 1 is 5, put back into score
- print shows 5
Answer: 5
Check: The box can change. That is why it is variable.
Example 3 — Two boxes
a = 3 b = 4 print(a + b)
- a holds 3, b holds 4
- a + b computes 7
- print shows 7
Answer: 7
Check: Exactly 3 + 4 in algebra.
Common mistakes
Slip print("score") when you wanted the number in score.
Fix Quotes print the word. No quotes prints the box.
Look at the quotes first when output looks “too wordy”.
Slip Reading score = score + 1 as a lying equation 4 = 5.
Fix In Python = means assign, not “both sides already equal”.
Read it as “new score is old score plus one”.
Slip Using a variable before you set it.
Fix Name the box first.
Sequence lesson again.
Try on paper first
Write the answer, then tap Reveal. These are not the quiz — they are warm-ups.
1. What is in x after x = 10?
Answer: 10
2. What does print("x") show if x = 10?
Answer: the letter x
3. After n = 2 and n = n * 5, n is…
Answer: 10
4. Python = at beginner level mainly means…
Answer: Store / assign into the box
Touch practice
9 tap / typeTap or type. Use the hint if you need it. Retry any miss — the why is the lesson.
Optional picture lab
After practiceReal world
A labelled box on a shelf.
Connect
x = 5 in maths and in Python.
⭐ Star quiz
9 questionsDo the worked examples and touch practice first. Then take the quiz without peeking.