Registry Synced

Variables and State

152 words
1 min read

Variables and State

Variables are labels attached to values. The label can point at a new value later, which means a program has state that changes over time.

Core idea

An assignment like score = score + 1 should be read in two phases:
  • Read the current value of score.
  • Store the new value back under the same name.

Trace habit

Create a tiny table:
StepCodeState
1score = 0score: 0
2score = score + 1score: 1
This table prevents a common beginner mistake: thinking both sides of = update at the same time.

Practice

Trace this mentally before running it:
python
level = 2
level = level + 3
level = level * 2
print(level)
The final value is 10.
Document Outline
Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.