>> Special Topics / 01 / Lecture
How a Computer
Actually Works
A tour inside the box
You've written code for weeks. But what is that code running on?
Today we open the lid and look at the machine underneath every Python program you've ever written.
Builds on
Day 1 — binary & bits
Series
ST · How It Really Works
ST 01 / 03
>> Today's roadmap
Six stops inside the machine
- The big picture — the four parts every computer has
- Everything is bits — and why that's enough
- The CPU — fetch, decode, execute, repeat (billions/sec)
- The memory hierarchy — fast-and-tiny vs slow-and-huge
- RAM vs storage — the confusion that trips everyone up
- From your Python down to the silicon
>> The hook
A computer can only do one thing.
It moves numbers around and does simple arithmetic on them — add, compare, copy. That's it.
No "open browser", no "play video", no "run Python". Just tiny operations on numbers,
done billions of times a second.
Everything else — your game, your music, your Python program — is that one trick, stacked into towers
so tall they look like magic. Today we learn the trick.
>> 01 / 06 · The big picture
Every computer is these four parts
Your laptop, your phone, the server running this slide — same blueprint, drawn in 1945 and still true.
CPU
the worker — does the math
↔
Memory (RAM)
the desk — holds what's in use now
Storage
the drawer — keeps things long-term
↔
Input / Output
keyboard, screen, network — the outside world
>> 02 / 06 · Everything is bits
One wire, two states — that's the whole alphabet
it_is_all_numbers
# A bit = one wire: ON (1) or OFF (0)
# 8 bits = 1 byte = one of 256 values
01001000 → the number 72 → the letter 'H'
01101001 → the number 105 → the letter 'i'
# Same bits, different meaning:
# as text → "Hi"
# as a pixel→ a shade of grey
# as sound → a speaker position
It's all the same stuff.
Text, images, video, your Python file — every one is just bytes. The meaning comes from the program reading them.
CALLBACK · DAY 1
This is the binary you met on your very first day — now you see why it matters: bits are the only thing the machine can hold.
>> 03 / 06 · The CPU
Fetch · Decode · Execute — forever
The CPU runs one tiny loop, over and over. Each lap handles one instruction.
FETCH
grab next instruction from memory
→
DECODE
figure out what it means
→
EXECUTE
do it (add, copy, compare…)
↳ then back to FETCH for the next one → repeat ~3,000,000,000 times per second
>> The CPU, a little closer
The clock, the cores, and the scratchpad
Clock speed
How many laps per second. 3 GHz = 3 billion/sec. Higher = each core does more work per second.
Cores
How many laps at once. 8 cores = 8 workers running the fetch-decode-execute loop in parallel.
Registers
A handful of tiny slots inside the CPU holding the numbers it's working on right this instant. The fastest memory there is.
>> 04 / 06 · The memory hierarchy
Fast costs money, so you get a little of it
The CPU needs data instantly, but fast memory is tiny and expensive. So computers stack layers: small & blazing at the top, huge & slow at the bottom.
Registers
inside the CPU
~1 ns · a few bytes
Cache (L1–L3)
on the CPU chip
~5 ns · a few MB
RAM
the sticks on the board
~100 ns · 8–32 GB
SSD / Disk
long-term storage
~100,000 ns · 256 GB–2 TB
>> 05 / 06 · The classic confusion
RAM vs Storage — not the same thing
RAM — the desk
- Working space — holds what's open right now.
- Fast, but forgets everything when power is cut.
- Measured in GB: 8, 16, 32.
- "My laptop is slow with 20 tabs" → out of RAM.
STORAGE — the drawer
- Long-term shelf — your files, photos, OS.
- Slower, but remembers with the power off.
- Measured in GB/TB: 256 GB, 1 TB.
- "I'm out of space for photos" → out of storage.
>> 06 / 06 · Bringing it home
Your Python, all the way down
The CPU can't read print("hi"). So Python translates, step by step, until it's numbers the CPU understands.
from_you_to_the_chip
"print('hi')" # 1. You write this — text a human reads
↓
bytecode # 2. Python compiles to simple steps (LOAD, CALL...)
↓
interpreter # 3. The Python program runs each step...
↓
machine code # 4. ...which the CPU runs as raw instructions
↓
01011010 11000001 # 5. fetch → decode → execute → "hi" on screen
>> Try it yourself
Two-minute explorations
LOOK
Find your own specs
Open your system info. Find your CPU cores & GHz, your RAM, and your storage. Label each with which of today's four parts it is.
THINK
Explain the slowdown
Your friend says "my PC is slow, I'll delete photos to fix it." Using RAM vs storage, explain why that probably won't help — and what might.
>> End of Special Topic 01
What you can now picture
-
✓
The four parts — CPU, RAM, storage, I/O — and the bus between them.
-
✓
The CPU's one loop — fetch, decode, execute — run billions of times a second.
-
✓
Why RAM forgets and storage remembers — and what "out of memory" really means.
-
✓
How your Python becomes numbers the silicon can run.