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.

The Three Basic Constructs

Every program, no matter how complex, is built from just three fundamental constructs:

ConstructDescriptionExample
SequenceInstructions executed one after another, in orderLines of code running top to bottom
SelectionThe program chooses which instructions to execute based on a conditionif / else statements
IterationA set of instructions is repeated multiple timesfor 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.

How It Works

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.