What Is a Program?
Instructions for a computer — and how Python runs them.
3 minute read
Big idea
A program is a list of instructions that a computer follows, one step at a time, top to bottom.
The idea
A computer can't think. It can only follow instructions — very fast and very exactly. Writing a program means writing those instructions down in a language the computer can be made to understand.
Python is one of those languages. It was designed to read almost like English, so you spend your energy on the idea rather than on punctuation.
Here's a complete Python program:
print("Hello!")
print("I am a program.")
Two instructions. The computer does the first, then the second. That's it.
How Python runs your code
The computer's brain, the CPU, only understands machine code — long strings of numbers. Python code is text. Something has to bridge the gap.
That something is the Python interpreter: a program that reads your code one line at a time and carries out each instruction straight away.
C uses a compiler, which translates the whole program first and runs it afterwards. Python skips that separate step: you write, you run, you see. That fast loop is why Python is so friendly to beginners.
Try it
Every box with a Run button in this course is real Python. Press Run:
print("Hello!")
print("I am a program.")output
Hello!
I am a program.Run and edit it in the app.
Order matters
The computer follows your instructions in the exact order you wrote them. Swap the lines and the output swaps too:
print("Put on socks")
print("Put on shoes")
print("Tie laces")What does it print? Show the answer
Put on socks
Put on shoes
Tie lacesRun and edit it in the app.
Watch it
Think of it like
A recipe. Each line is one step: "crack the eggs", "whisk", "pour into the pan". The cook (the interpreter) reads a step, does it, then moves to the next. Steps in the wrong order give you a very strange omelette.
Why Python?
- Readable. Short programs that look close to plain English.
- No setup ceremony. No
main, no semicolons, no types to declare up front. - Everywhere. Scripting and automation, websites, data analysis, and almost all of machine learning.
Key terms
- Program — A list of instructions for the computer.
- Interpreter — The program that reads Python code and runs it line by line.
- Output — What a program shows you, like text on the screen.
Check yourself
What is a program?
What does the Python interpreter do?
In what order does Python run the lines of a simple program?