Skip to content
BENIBIX Learn

Assignment

Development🧩 Programming ConceptsData and Variables

Also known as Variable Assignment, Assignment Statement

The step that puts a value in a variable. Most languages use one = sign.

Think of it like

Think of it like a label you stick on a jar of jam.

Example

Lucy writes total = 5 + 3. Python works out 8, then stores 8 under the name total.

Why it matters

Every variable gets its value through assignment. Reading = as store makes lines like count = count + 1 clear.

Definition

Assignment is the step that puts a value into a variable. In most languages it uses a single equals sign, like age = 12. The right side is worked out first, then stored under the name on the left. So count = count + 1 makes sense: take the old count, add one, store it back. The equals sign here means store, not is equal to.

Example code

python
>>> count = 1
>>> count = count + 1
>>> count
2
The right side is worked out first, then stored back in count.

Common mistake

Using one = to compare two values. Most languages use == for that, and mixing them up is a classic bug.

Key takeaways

  1. 1
    Right side first. The value is worked out, then stored.
  2. 2
    Store, not equal. One = sign means put this in that box.
  3. 3
    Replaces the old. The new value takes the old one's place.

Learn it properly