Concept Flow - Why variables are needed
Start
Need to store data?
Yes
Create variable
Assign value
Use variable in code
Change value if needed
End
This flow shows how variables help us store and use data in a program step-by-step.
Jump into concepts and practice - no test required
name = "Alice" age = 30 print(name) print(age)
| Step | Action | Variable | Value | Output |
|---|---|---|---|---|
| 1 | Assign 'Alice' to name | name | "Alice" | |
| 2 | Assign 30 to age | age | 30 | |
| 3 | Print name | name | "Alice" | Alice |
| 4 | Print age | age | 30 | 30 |
| 5 | End of program |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | After Step 4 | Final |
|---|---|---|---|---|---|---|
| name | undefined | "Alice" | "Alice" | "Alice" | "Alice" | "Alice" |
| age | undefined | undefined | 30 | 30 | 30 | 30 |
Variables store data with a name. Assign values using =. Use variables to print or calculate. Variables can change values anytime. They help reuse and update data easily.
age with the value 25 in Python?variable = value to assign values.name = "Anna"
print("Hello, " + name)name holds "Anna". The print joins "Hello, " and the value of name.number = 10 print(numer)
number, but print uses numer, which is undefined.numer does not exist.price1, price2, and price3 must be assigned values before adding.