Definition
How do you write steps any programmer, in any language, can follow?
Pseudocode is an algorithm written in structured plain language, using a few keywords such as IF, ELSE, WHILE and FOR, without the strict rules of a real programming language. A flowchart shows the same algorithm as a diagram, using standard shapes connected by arrows.
In simple words
Pseudocode is like a recipe written neatly: each line is one step, and indented lines belong to the step above. A flowchart is the same recipe as a map you can follow with your finger. Every algorithm is built from three ideas: sequence (do this, then that), selection (if this, do that) and repetition (do this again).
Overview
- Pseudocode writes an algorithm in structured plain language that looks like code but follows no strict syntax.
- A flowchart draws the same algorithm as connected shapes, so the flow of control can be seen at a glance.
- Both use the three basic structures of all programs: sequence, selection (decisions) and iteration (loops).
- Standard flowchart shapes were set out in ISO 5807, so people anywhere can read each other's charts.
- Pseudocode is faster to write and edit; flowcharts are easier to explain to non-programmers.
- Planning this way catches logic mistakes before any code is typed.
Why it matters
Teams plan programs in pseudocode and flowcharts before writing code, and exams and interviews use them to test thinking without language details. Once you can write pseudocode, turning it into Python is mostly translation.
Key terms
- Pseudocode
- An algorithm written in structured plain language with a few keywords, not tied to any programming language.
- Flowchart
- A diagram of an algorithm using standard shapes joined by arrows.
- Sequence
- Steps executed one after another.
- Selection
- Choosing between paths with IF and ELSE.
- Iteration
- Repeating steps with WHILE or FOR.
- Indentation
- Shifting lines to the right to show which steps belong inside a block.
Types
A flowchart is built from a small set of standard symbols, each with one meaning. These are the types you must know.
1. Terminator (start/end)
A rounded rectangle or oval marking where the algorithm begins and where it stops.
- How it works: Every flowchart has exactly one Start and at least one End; arrows lead out of Start and into End.
- Example: "Start" at the top of a chart for making tea, and "End" after "Serve tea".
- When to use it: Use it at the very beginning and every finishing point of the chart.
2. Process
A rectangle holding one action or calculation.
- How it works: It has one arrow in and one arrow out; the steps inside happen in order, such as assigning a value or doing arithmetic.
- Example: "total = total + marks" or "Boil water for 2 minutes".
- When to use it: Use it for every ordinary step that changes data or does work.
3. Decision
A diamond holding a yes-or-no question.
- How it works: One arrow enters; two arrows leave, labelled Yes and No (or True and False), and the flow follows the matching branch.
- Example: "Is marks ≥ 33?" leading to "Pass" on Yes and "Fail" on No.
- When to use it: Use it for every if-condition and for the test that decides whether a loop repeats.
4. Input/Output
A parallelogram for reading data in or showing results out.
- How it works: It marks the points where the algorithm talks to the outside world: a keyboard, a file, a sensor or a screen.
- Example: "Read the student's name" or "Print the average".
- When to use it: Use it whenever data enters or leaves, so readers can see what the algorithm needs and produces.
5. Connector and flow lines
Arrows show the order of steps; small circles (connectors) join parts of a chart that would otherwise cross or continue on another page.
- How it works: Arrows point from each step to the next; a loop is drawn as an arrow going back up to an earlier decision; matching letters in connectors link distant points.
- Example: An arrow from "count = count + 1" back to "Is count ≤ 10?" draws a loop.
- When to use it: Use arrows everywhere to show flow, and connectors when a chart is too large to draw without crossing lines.
Explained in detail
Why write pseudocode
Pseudocode sits between plain English and a programming language. It is precise enough to show every step and decision, but free from details such as brackets, colons and exact function names. That lets you concentrate on the logic. Teams use it to agree on an approach before anyone writes real code, examiners use it so that answers do not depend on one language, and textbooks use it to describe algorithms that can then be written in Python, Java or C.
Common conventions
| Keyword | Meaning | Python equivalent |
|---|---|---|
| INPUT x | Read a value | x = input() |
| OUTPUT x | Show a value | print(x) |
| x ← 5 | Store 5 in x | x = 5 |
| IF … THEN … ELSE … ENDIF | Choose a path | if …: … else: … |
| WHILE … ENDWHILE | Repeat while true | while …: |
| FOR i ← 1 TO n … NEXT | Count through values | for i in range(1, n + 1): |
There is no single official standard, and that is fine. What matters is consistency: use the same keywords throughout, indent the steps inside each IF and loop, and write one action per line.
Flowcharts for the same logic
A flowchart shows the same algorithm visually: ovals for start and end, parallelograms for input and output, rectangles for processing, diamonds for decisions and arrows for flow. Flowcharts make branches and loops easy to see at a glance, which helps when explaining an algorithm to people who do not program. Pseudocode is quicker to write and to change, and closer to real code. Many developers sketch a flowchart for the overall shape, then write pseudocode for the details.
From pseudocode to Python
- Replace INPUT with input() and convert the type if you need a number.
- Replace ← with =.
- Turn IF … THEN into if …: and keep the indentation.
- Drop ENDIF and ENDWHILE, because Python ends blocks by indentation.
- Test with the same examples you traced by hand.
A good test of pseudocode is to hand it to a classmate who has not seen the problem and ask them to trace it with a small example. If they have to ask you what a step means, the pseudocode is not yet precise enough.
How it works
Pass or fail, in pseudocode
READ mark
IF mark >= 40 THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
END IF| Flowchart shape | Meaning |
|---|---|
| Rounded rectangle (oval) | Start or end |
| Parallelogram | Input or output |
| Rectangle | A process step, such as a calculation |
| Diamond | A decision with yes and no arrows |
| Arrow | The direction to go next |
The three building blocks
- Sequence: steps one after another.
- Selection: IF … ELSE, a diamond in a flowchart.
- Repetition: WHILE or FOR, an arrow that loops back.
Try it yourself
Match each shape to its meaning
Choose the meaning of each flowchart shape.
- Diamond
- Parallelogram
- Rectangle
- Oval
Turn a flowchart into pseudocode
The flowchart counts from 1 to 5. Put its pseudocode lines in order.
- 1SET count TO 1
- 2WHILE count <= 5
- 3 OUTPUT count
- 4END WHILE
- 5 SET count TO count + 1
Common mistakes
- Writing pseudocode so vague that it is just prose.
- Forgetting the 'no' arrow from a decision diamond.
- Creating a loop that never ends because the counter never changes.
Check yourself
Summary
- Pseudocode is structured plain language; flowcharts are the same steps as shapes.
- Sequence, selection and repetition build every algorithm.
- Good pseudocode translates almost line by line into Python.
Finished reading?