Hardware and software
Hardware is the physical computer: the CPU (the processor) that does the work, the memory that holds what it is working on, and the screen and keyboard. On its own, hardware does nothing at all.
Software is the instructions that tell the hardware what to do. A program is like a recipe: exact steps, done in order. This one has four steps: it adds two numbers and shows the answer.
A computer needs exact rules, not everyday English, so people write programs in a programming language. Here is the same recipe in Python: each line on the right means the line beside it on the left.
Running the program
Running starts at the top. The CPU, like a cook, reads one instruction and does it. a = 2 means: put 2 in a box called a. Memory, the kitchen counter, now holds it.
Then the next line, and only then. The CPU reads b = 3 and puts 3 in a second box called b. Instructions run in order, one after another, exactly as written.
This line needs both boxes. The CPU reads 2 from a and 3 from b, adds them, and puts the answer, 5, in a new box called total. The boxes a and b keep their values.
print shows a value on the screen. The CPU takes 5 from total and sends it to the screen. This is how a program talks to you; the keyboard is how you talk back. No lines are left, so the program stops.
Many programs
Change the instructions and the same hardware does something else. A calculator, a game and a web browser are just different programs: the computer loads one into memory and the same CPU runs it, line after line.
All of these are software: the apps on your phone, the operating system that starts the machine and runs the rest (like Windows, macOS or Android), and websites. People write the instructions; hardware carries them out.
What happens
;; step 1/9 · hardware hardware the parts you can touch CPU central processing unit: carries out instructions memory holds the program and the values it is using screen output: how a program shows you things keyboard input: how you type to a program with no instructions, none of it does anything
Real CPUs work on several machine instructions at once, and one Python line becomes many tiny machine instructions. The result is the same as doing them one at a time, in order, which is how the figure shows it. The labelled boxes are a simplification. In Python a name such as a refers to an object (here the number 2) kept in memory, and memory itself is numbered by address, not by name.