Drop hier links of afbeeldingen om ze aan de editor toe te voegen.

Before a computer can carry out the “process” step from the previous activity, someone has to describe exactly what to do, in an order the computer can follow without any guesswork. That description is called an algorithm.

An algorithm is a sequence of instructions for a task.

Algorithms outside of computing

Algorithms are not unique to computers. Anything with a fixed set of steps, followed in order, is an algorithm:

Change the order of the steps, or skip one, and the result changes too, or stops working entirely. That is exactly what makes something an algorithm rather than just a vague idea: it has to be precise enough that someone else (or something else) could follow it and get the same result.

An algorithm is not the same thing as a computer program. An algorithm is the idea, the plan of steps. A program is that plan written in a language a computer can actually run.

From algorithm to program

Algorithms that are converted into code become computer programs. Take the simplest possible algorithm:

OUTPUT "Hello, World"

That single instruction can be turned into a program in more than one language. In a block-based language like Scratch, it looks like this:

Scratch blocks: when the green flag is clicked, say "Hello, world!", then stop this script

In Python, the same algorithm is one line of text:

print("Hello, World!")

Both versions do exactly the same thing: they run the same algorithm. Scratch expresses it as blocks that snap together, and Python expresses it as text that follows precise rules. This course uses Python.

Try it yourself

print("Hello, World!")

Run it, then change the text between the speech marks and run it again. From here on, you will be writing algorithms as Python programs yourself. The next chapter starts with the simplest Python statement of all: printing text to the screen with print.