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)

KeywordWhat it means
INPUT / READAsk the user for a value and store it.
SET / ←Give a variable a value (assignment).
OUTPUT / PRINTShow a value or message to the user.
IF ... ELSEMake a decision; do one thing or another.
WHILERepeat steps while a condition stays true.
FORRepeat steps a fixed number of times.
REPEAT ... UNTILRepeat 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.

Start READ name message = "Hello, " + name PRINT message End

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.