One-sentence summary
Pseudocode is a way of writing the steps of a solution in an organised, easy-to-read form, without tying yourself to any particular programming language.
Why does it matter?
When we solve a problem, we really do two jobs at once: first we decide what to do, then we translate that into a language. Doing both at the same time makes thinking harder.
Pseudocode separates these two jobs. First we write the logic of the solution in plain sentences. The semicolons, brackets and rules of a language do not slow us down. Once the logic is clear, translating it into Python, Scratch or another language becomes much easier.
Before I code a robot task, I often write pseudocode on paper first. Seeing the steps as plain sentences helps me notice which step is missing.
What is pseudocode?
Pseudocode means writing an algorithm in a form that is close to everyday language but still organised. The word "pseudo" means "looks like the real thing, but is not the real thing."
Its purpose is not to be run directly by a computer. Its purpose is to help a person see the logic of the solution clearly.
Language independence
The best part of pseudocode is that it does not belong to any one language. The same pseudocode can be translated into Python, into Scratch, or into another language.
For example, the step "add two numbers and display the result" is valid in every language. Only the writing style changes; the idea stays the same.
Writing habits
There is no strict rulebook for pseudocode, but good habits make it easier to read:
- Keep one action on each line.
- Use clear words instead of vague ones ("3 times" instead of "a few times").
- Add a beginning and an ending.
- Indent a step when it belongs inside another step.
Structure through indentation
Indentation shows which step depends on which. We shift the lines inside a condition or a repetition slightly to the right. This makes the idea "this line only runs in that case" visible to the eye.
If the weather is rainy
take the umbrella
put on the boots
End
The two indented lines above run only when the weather is rainy. Without indentation, this would be harder to see.
Core keywords
In pseudocode we use a few keywords with the same meaning every time. That way everyone can read the same style.
Start and End
Every piece of pseudocode opens with a Start and closes with an End. These two words show where the solution begins and where it finishes.
If and Otherwise
If marks the steps that run when a condition is true. Otherwise marks the steps that run when the condition is false.
If the score is greater than or equal to 50
display "Passed"
Otherwise
display "Failed"
repeat
repeat is used to run the same steps more than once.
Repeat 5 times
display "Hello"
Example 1: Finding the largest number
Goal: Find the largest of three numbers. In everyday life we do this when we compare the heights of three friends and pick the tallest.
Pseudocode
Start
Receive numbers a, b, c
largest = a
If b > largest
largest = b
If c > largest
largest = c
Display largest
End
First we assume the first number is the largest. Then we compare the others one by one and update the largest if needed.
Python version
a = int(input("1st number: "))
b = int(input("2nd number: "))
c = int(input("3rd number: "))
largest = a
if b > largest:
largest = b
if c > largest:
largest = c
print("Largest number:", largest)
The logic of the pseudocode and the logic of the Python are exactly the same. Only the writing style changed.
Example 2: Counting items in a list
Goal: Count the students in a class who wear glasses. In everyday life we do this by counting on our fingers: we start from zero and add one for each person with glasses.
Pseudocode
Start
counter = 0
For each student in the list, repeat
If the student wears glasses
counter = counter + 1
Display counter
End
Here we use a counter. A counter starts at zero and increases by one each time the condition is met.
Python version
students = ["glasses", "no glasses", "glasses", "no glasses"]
counter = 0
for student in students:
if student == "glasses":
counter = counter + 1
print("Students with glasses:", counter)
When this code runs, the result is 2.
Mini practice
You go to a shop with 50 liras in your pocket. Write pseudocode that looks at the price of an item you want and tells you whether you have enough money.
Try to include:
- A Start and an End.
- Two values for the price and your money.
- An If / Otherwise condition.
- Clear lines with one action each.
After you finish, ask yourself: Are my steps clear? Is the indentation correct? Could another person read and follow it?
Practice lab: Writing Pseudocode
The best way to retain Writing Pseudocode is to turn the idea into a small, measurable task. In this activity you will connect What is pseudocode? with Writing habits and produce a clear algorithm, pseudocode and a test table. The aim is not only to make the result work. You should also be able to explain why you made each decision, what you tested and which observation would make you revise the design.
Challenge scenario
Work with this scenario: a decision flow that counts repetitions in a sports drill. Because the main goal of the lesson is to “Learn to write a solution as clear, language-independent pseudocode”, begin by defining the problem in one sentence. Then write the input, the process and the output separately. Mark anything you do not know as an assumption rather than presenting it as a fact.
- Plan: Record the starting state, expected result and the concepts you will use.
- Build the smallest version: Make only the essential behaviour work before adding decoration or extra features.
- Prepare three tests: Choose a normal case, a boundary case and an invalid or unexpected case.
- Record the result: Put the expected and actual results side by side and name a likely cause when they differ.
- Change one thing: Revise one decision and repeat the test instead of changing several parts at once.
Success criteria
- Are the steps clear and unambiguous?
- Are the start and finish conditions defined?
- Were normal, boundary and invalid cases tested?
- Is there an unnecessary step or repetition?
- Can another person follow the algorithm and obtain the same result?
After completing “Writing Pseudocode”, explain the work to a classmate using only the section headings. If the classmate can follow the decisions in the scenario of a decision flow that counts repetitions in a sports drill, the explanation is clear enough. Fix an unclear point by dividing the relationship between What is pseudocode? and Writing habits into smaller steps rather than adding jargon.
Common mistakes
Thinking pseudocode is runnable code
Pseudocode does not run directly on a computer. It is a plan, not a program. To run it, you first have to translate it into a real language.
Leaving steps vague
The sentence "compare the numbers" is vague. Which numbers? Compared how? Where does the result go? Good pseudocode keeps every step single and clear.
Forgetting the start and the end
Without a Start and an End, it stays unclear where the solution begins and finishes. These two words look small, but they make the structure clear.
Lesson summary
- Pseudocode is a way to write the logic of a solution in an organised form, independent of any language.
- The same pseudocode can be translated into different programming languages; the logic does not change.
- Start, End, If, Otherwise and repeat are the basic keywords.
- Indentation shows which step depends on which.
- Pseudocode is a plan; to run it, you must translate it into a real language.
Check questions
- What is the main purpose of pseudocode?
- What does "pseudocode is language independent" mean?
- In the largest-number example, why is the first number assigned to
largestin the first step? - What does indentation do in pseudocode?
- Does pseudocode run directly on a computer? Why or why not?
Answers
- To write the logic of a solution as clear, human-readable steps, without dealing with the rules of a programming language.
- It means the same pseudocode can be translated into Python, Scratch or any other language; the idea stays the same and only the writing style changes.
- A comparison needs a starting value. We temporarily assume the first number is the largest, then compare it with the others and update it if needed.
- It shows that a step belongs inside another step (a condition or a repetition); it makes the structure visible.
- No. Pseudocode is a plan, not a program. To run it, you must first translate it into a real language such as Python.
Source and verification note
For “Writing Pseudocode”, verification focuses on whether the relationship between What is pseudocode? and Writing habits remains consistent across examples. The algorithms in this lesson are checked by tracing sample inputs by hand and comparing them with expected outputs. Pseudocode is used to make the reasoning sequence visible without tying it to one programming language.
Next lesson
Flowcharts: We will learn to picture the same solution logic with boxes, arrows and decision symbols.