A program is a sequence of instructions written in a text file that the Python interpreter executes line by line, from top to bottom. Each instruction tells the computer to perform a specific action — display text, calculate a result, store a value, and so on.
Every program, no matter how complex, is built from just three fundamental constructs:
| Construct | Description | Example |
|---|---|---|
| Sequence | Instructions executed one after another, in order | Lines of code running top to bottom |
| Selection | The program chooses which instructions to execute based on a condition | if / else statements |
| Iteration | A set of instructions is repeated multiple times | for and while loops |
In this chapter we focus on sequence — writing programs where every line runs in order. You will meet selection and iteration in later chapters.
When you submit your Python code on Dodona, the Python interpreter reads your file and executes each line in turn. If it encounters an error, it stops and reports what went wrong. If everything is correct, your program runs to completion and produces its output.
>>> print("Hello!")
Hello!
>>> print("This runs second.")
This runs second.
The two print() statements above run in sequence — first line, then second line. This is the simplest form of a program.