RAM and storage
When you assigned score = 15 in unit 3, where did the 15 actually go? Into RAM (random-access memory), the computer's fast working memory. RAM is a huge row of numbered byte-sized slots. Each slot's number is its address, like a house number on a very long street. A variable name is your friendly label for "the value at some address", so the labeled-box picture from lesson 3-1 was literal.
RAM has a catch: it is volatile, meaning it is wiped when the power goes off. That is why computers also have storage (an SSD or hard drive): slower, but it keeps data permanently as files.
The everyday consequences:
- Running programs and their variables live in RAM
- Saving a document copies data from RAM to storage
- "Have you tried turning it off and on again?" works partly because a restart clears RAM, discarding whatever bad state a program had built up
Code exercise · python
Copying a variable copies the VALUE into b's box, not the label. Predict the output, then run: does changing a afterward affect b?
Quiz
You spent an hour typing a document and the power cuts out before you hit save. Why is the work gone?
Problem
What is the name for the number that identifies one specific slot in RAM (like a house number on a street)?
Reading memory sizes
Engineers talk about memory and storage in units built from the byte (lesson 6-1's group of 8 bits), and you will see these numbers daily — in laptop specs, error messages, and cloud bills:
- a kilobyte (KB) is 1,024 bytes (1,024 rather than 1,000 because memory hardware is organized around powers of 2: 1,024 is 2 multiplied by itself 10 times)
- a megabyte (MB) is 1,024 KB — a phone photo is a few MB
- a gigabyte (GB) is 1,024 MB — laptops today carry 8 to 32 GB of RAM
So "this laptop has 16 GB of RAM" means roughly 17 billion labeled byte slots for running programs to use.
Code exercise · python
Your turn. Print how many bytes are in 4 GB by chaining multiplications: 4, times 1024 (GB to MB), times 1024 (MB to KB), times 1024 (KB to bytes). One print line — make Python compute it.