Memory is the worktable
RAM keeps the things a program is using now. The table can be cleared when the program or device stops.
02MEMORY + VARIABLES
Memory gives a program a small place to keep what it needs right now.
FIRST: COMPUTER MEMORY
RAM keeps the things a program is using now. The table can be cleared when the program or device stops.
Files and saved progress can stay for later. They are not the same as the program's working memory.
robot_color = "orange" puts one value under a useful name.
Use robot_color later, and Python uses the value orange.
THE = SIGN
Let's go slowly, one small step at a time.
First write the name of the box. Then =. Then what goes inside.
Read stars = 5 like this: stars gets 5. Python puts 5 inside the box.
stars = 5→A box holds one value. The new value goes in and the old one goes out. = never adds.
stars = 5→stars = 8→A number or a text in quotes goes straight into the box.
pet = "cat"→Python solves the right side first. Only the answer goes into the box.
total = 3 + 4→7→Python opens the box on the right, copies its value, and puts the copy in the box on the left.
my_stars = stars→RUN IT
Guess first. Then run real Python and check.
robot_color = "orange"
print(robot_color)What will Python show?
PyBot's hint
Ready. Press Run Python.
Pyodide 314.0.3 runs CPython in your browser with WebAssembly.
Open-source under the Mozilla Public License 2.0. License
Now change one thing: Put your favorite color between the quotes. Run again.
YOUR TURN
Try each tiny question. A wrong answer becomes something to review.
Which place is like the worktable?
stars = 5What is the variable's name?
stars = 5What value is stored?
stars = 5
stars = 8
print(stars)What will Python show?
Which name helps the most?
Which line puts 10 in the box points?
total = 3 + 4
print(total)What will Python show?
a = 6
b = a
print(b)What will Python show?
PyBot misspelled its box's name. Fix it so Python finds the box.
catOUTPUT
Want a fresh start? Clear only this page.
The name helps people and Python find the value again.