---
title: "Variables and Assignment in Text Code"
description: "Storing a value under a name in written code, then replacing it later. The name holds whatever was last assigned to it, which is how a program remembers anything."
canonical: https://lightmysky.com/learn/computing/variables-and-assignment-in-text-code-mt_uLHLaX8BQq
source: https://lightmysky.com/learn/computing/variables-and-assignment-in-text-code-mt_uLHLaX8BQq.md
retrieved: 2026-09-12
---

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# Variables and Assignment in Text Code

Storing a value under a name in written code, then replacing it later. The name holds whatever was last assigned to it, which is how a program remembers anything.

Subject: Computing · Area: Programming · Ages 14 to 15
Page: https://lightmysky.com/learn/computing/variables-and-assignment-in-text-code-mt_uLHLaX8BQq

## Ready when they can

- Assign a value to a name and print it back out
- Predict what a name holds after two assignments in a row
- Pick names that say what the value means instead of single letters

## Lesson: Names that remember

A variable is a named box holding one value. You create it with an assignment: the name on the left, the value on the right. In text code you write score = 0, and from then on score means 0.

**Example.** Programs remember by reassigning. Start with score = 0, then later write score = 5 after a goal. The same name now holds 5, and the old 0 is gone for good. To show a value, print it back out.

Values come in kinds. Text sits in quotes, like name = "Lia", while numbers stand bare, like age = 14. True and false stay lowercase with no quotes. Each kind behaves differently when your program uses it.

**Tip.** Pick names that say what the value means. Player score beats x every time, because future you will read this code. Short single letters hide meaning, while clear lowercase names reveal it.

**Recap.** Store a value under a clear name, print it to show it, and reassign to change it.

## Practice

8 questions on this page, each with its working shown.

## Needs first

- [Programming with Loops and Variables](https://lightmysky.com/learn/computing/programming-with-loops-and-variables-mt_9x5zgShXPg)
- [Writing an Algorithm Down: Flowcharts and Pseudocode](https://lightmysky.com/learn/computing/writing-an-algorithm-down-flowcharts-and-pseudocode-mt_RCm-4b4Lof)

## Opens up

- [Input, Output and Type Conversion](https://lightmysky.com/learn/computing/input-output-and-type-conversion-mt_lZmkGSELbC)
