Algorithms & Flowcharts — Worked Examples
2. Pseudocode: Writing Algorithms in Plain Steps
Pseudocode: Writing Algorithms in Plain Steps
Pseudocode is a way of writing an algorithm in short, structured English. It is not any real programming language, so the computer cannot run it — but it reads almost like code, so it is the perfect bridge between an idea in your head and a program in Python. You think in pseudocode, then translate it line by line into real code.
Why pseudocode helps
- It lets you plan the logic without worrying about exact Python punctuation and spelling.
- It is easy for any human to read and check.
- Each pseudocode line usually becomes one line of real code, so translation is simple.
Common pseudocode keywords (conventions)
| Keyword | What it means |
|---|---|
INPUT / READ | Ask the user for a value and store it. |
SET / ← | Give a variable a value (assignment). |
OUTPUT / PRINT | Show a value or message to the user. |
IF ... ELSE | Make a decision; do one thing or another. |
WHILE | Repeat steps while a condition stays true. |
FOR | Repeat steps a fixed number of times. |
REPEAT ... UNTIL | Repeat steps until a condition becomes true. |
We indent the lines inside an IF, WHILE or FOR so it is obvious which steps belong together — exactly as Python will later force us to do.
A tiny example: greet the user by name
Problem
Ask the user for their name, then print a friendly greeting that includes it.
Pseudocode
START INPUT name SET message = "Hello, " + name OUTPUT message END
In Python
name = input("What is your name? ")
message = "Hello, " + name
print(message)
Output: (if the user types Ada)
Hello, Ada
Notice how each pseudocode line turned into one Python line. That is the whole point of pseudocode: plan it in plain steps, then translate.