A map before the trip#
Furniture instructions rarely start with a wall of text. They show pictures in order with arrows between them: do this, then this, and if the shelf has holes on the left, go to step 7. You can follow the whole build before touching a screwdriver.
A flowchart is that kind of picture for a program. Each step sits in a box, the shape of the box says what kind of step it is, and arrows show the order. Pseudocode is the same plan written as short, structured English lines instead of a picture. Neither one runs on a computer. Both exist so you can get the logic right before worrying about Python’s grammar, which is far cheaper than fixing a wrong program afterwards.
The five symbols#
Almost every flowchart in a first course uses just these five. Learn the shape and the meaning together, because exams often show a shape and ask what it is for.
| Shape | Name and meaning |
|---|---|
| Terminal (oval, rounded rectangle): where the program starts and where it ends. In Python: the first and last line; nothing to type. | |
Input / output (parallelogram): data coming in from the user, or results going out to the screen. In Python: input(...) or print(...). | |
Process (rectangle): a calculation or assignment: something is worked out or stored. In Python: total = total + score. | |
Decision (diamond): a yes/no question; two arrows leave it, labelled Yes and No. In Python: if or while with a condition. | |
| Flow line (arrow): which step comes next. In Python: the order of the lines. |
The two that get swapped are the parallelogram and the rectangle. A quick test: if the step talks to a person (asking them something, or showing them something), it is a parallelogram. If it only works inside the computer, it is a rectangle.
Drawing a decision#
A diamond holds a question with a yes-or-no answer, and in a first course exactly two arrows leave it. (The formal flowchart standard allows a diamond with more exits, one per possible answer, but Yes/No is what you will be asked to draw.) Each arrow is labelled so there is no doubt which way is which. After the two paths do their different jobs, they usually join up again and carry on.
Turning that chart into Python is almost mechanical: the oval disappears, the parallelograms become input and print, and the diamond becomes an if/else. To keep the listing runnable here, the input step is shown as a comment and the value is set directly:
# Input temperature (the full program would use: temperature = int(input("Temperature: ")))
temperature = 91
if temperature > 85:
print("Hot day")
else:
print("Mild")
Hot day
Try it with 70 in place of 91 and the other branch runs. The two paths joining before End is the moment the indented block finishes and the code carries on at the left margin.
Drawing a loop#
A loop in a flowchart is an arrow that goes back up to an earlier diamond. As long as the answer is Yes, the program goes round again; when it becomes No, the arrow leaves the loop.
count = 1
while count <= 5:
print(count)
count = count + 1
1
2
3
4
5
Every part of the picture has a line of code: the rectangle count = 1 before the loop, the diamond as the while condition, the output and the update inside the loop body, and the arrow back up is the loop itself. Forget the update box, and the arrow goes round forever: an infinite loop is easy to spot in a flowchart because nothing inside the loop ever changes the answer to the diamond’s question.
A trick for exams: trace a flowchart with your finger and a small table. Write each variable as a column and add a row every time a value changes. Here the table would show count going 1, 2, 3, 4, 5, 6, and the diamond answering No when it reaches 6.
Writing pseudocode#
Pseudocode (“pseudo” means “pretend”) is a plan written in structured English. It has no strict grammar, but good pseudocode follows a few habits:
- One step per line, in order.
- A small set of capitalised keywords for the structure:
INPUT,OUTPUT,SET,IF…ELSE,WHILE,FOR EACH,END IF,END WHILE. - Indentation to show which steps belong inside an
IFor a loop. - No language-specific details: no brackets, colons or quotation rules to worry about.
Here is a plan for averaging some test scores, written as pseudocode and then as Python:
SET total TO 0
SET count TO 0
FOR EACH score IN the list of scores
ADD score TO total
ADD 1 TO count
END FOR
IF count IS MORE THAN 0
SET average TO total DIVIDED BY count
OUTPUT "Average:", average
ELSE
OUTPUT "No scores entered"
END IF
scores = [72, 85, 91, 64]
total = 0
count = 0
for score in scores:
total = total + score
count = count + 1
if count > 0:
average = total / count
print("Average:", average)
else:
print("No scores entered")
Average: 78.0
The pseudocode already handled the case nobody thinks of until the program crashes: no scores at all, which would mean dividing by zero. Planning in English makes that kind of gap visible, because you are thinking about the problem rather than the punctuation.
A design process to follow#
Courses phrase it slightly differently, but the steps are always these:
- Understand the problem. Restate it in your own words. What exactly is being asked?
- Identify inputs, processing and outputs (IPO). What comes in, what must be calculated, what goes out? For the average: in, a list of scores; process, add and divide; out, the average.
- Design the algorithm as a flowchart or pseudocode.
- Desk-check it. Trace the plan by hand with a small example where you already know the answer.
- Write the code, one plan step at a time.
- Test with normal values, edge values (zero, one item, the boundary of an
if) and, where it matters, bad values.
The IPO step maps straight onto the shapes: inputs and outputs are parallelograms, processing is rectangles, and any “it depends” in the processing is a diamond.
Oval for start and end, parallelogram for input and output, rectangle for a process, diamond for a yes/no decision, arrows for the order. A diamond becomes an if; an arrow that goes back up becomes a loop.
Where these go wrong#
- Using a rectangle for
inputorprint. Anything that talks to the user is a parallelogram. - A diamond with one exit, or unlabelled exits. A yes/no decision has two arrows, marked Yes and No (or True and False).
- Putting a statement in a diamond. A diamond holds a question:
count <= 5?, notcount = 5. - A loop with nothing that changes the condition. In the chart, nothing inside the loop affects the diamond, so it never answers No.
- Forgetting the Start and End ovals. Exams mark them. Every flowchart has exactly one Start.
- Writing Python syntax in pseudocode. Colons and brackets are not needed. Clear, indented English is the goal.
Practice#
Answer each one on paper before you look at the solutions. Every answer that involves running code was checked by running it.
- Name each shape and say what it is used for: oval, parallelogram, rectangle, diamond.
- Which shape should hold each step? (a)
price = price * 1.07(b) ask the user for their name (c) is the balance below zero? (d) show the receipt - A flowchart sets
nto 3 andproductto 1, then asks “n > 0?”. On Yes it setsproduct = product * n, thenn = n - 1, and the arrow returns to the diamond. On No it outputsproduct. What is output? Write the matching Python. - Write pseudocode, then Python, for: read a number and say whether it is even or odd.
- List the inputs, processing and outputs (IPO) for a program that converts a temperature from Fahrenheit to Celsius.
- In a flowchart, how can you tell a loop from a decision that is not a loop?
Solutions#
- Oval: terminal, the start or end of the program. Parallelogram: input or output, such as asking for a number or printing a result. Rectangle: a process, such as a calculation or assignment. Diamond: a decision, a yes/no question with two labelled exits.
- (a) rectangle, a process. (b) parallelogram, input. (c) diamond, a decision. (d) parallelogram, output.
- Trace: product 3 (n becomes 2), 6 (n 1), 6 (n 0), then No. The output is 6, which is 3 factorial.
n = 3 product = 1 while n > 0: product = product * n n = n - 1 print(product)6 - Pseudocode:
INPUT number;IF number MOD 2 IS 0,OUTPUT "even",ELSEOUTPUT "odd",END IF. Python, with the input step set directly so it can run here:number = 14 if number % 2 == 0: print(number, "is even") else: print(number, "is odd")14 is even - Input: a temperature in Fahrenheit. Processing:
celsius = (fahrenheit - 32) * 5 / 9. Output: the temperature in Celsius. As a flowchart: Start, a parallelogram for the input, a rectangle for the formula, a parallelogram for the output, End. - A loop has an arrow that leads back up to an earlier diamond, so steps can repeat. A plain decision’s two paths only go forward and join up further down.
Test-readiness checklist#
These are the skills a first programming course tests on this topic. Tick each one only when you can do it without looking.
- ☐ I can name the flowchart symbols (oval, parallelogram, rectangle, diamond, arrow) and say what each is for.
- ☐ I can draw a decision with two labelled exits, and a loop with an arrow back to the diamond.
- ☐ I can trace a flowchart by hand with a table of variable values.
- ☐ I can write pseudocode for a short problem, using indentation for structure.
- ☐ I can turn a flowchart or pseudocode into Python, and Python back into a flowchart.
- ☐ I can list the design steps: understand, IPO, design, desk-check, code, test.
Test yourself in the free Kestrel Exams app
12 practice questions on flowchart symbols, tracing a flowchart, and turning pseudocode into Python. Free, offline, no account.
Practise flowcharts →Frequently asked questions#
What do the shapes in a flowchart mean?
An oval (terminal) marks the start or end. A parallelogram is input or output. A rectangle is a process, such as a calculation or assignment. A diamond is a decision: a yes/no question with two labelled exits. Arrows (flow lines) show the order of the steps.
What is the flowchart symbol for input and output?
A parallelogram. It is used both for input, such as asking the user for a value, and for output, such as printing a result.
How do you show a loop in a flowchart?
With an arrow that returns to an earlier decision diamond. While the condition in the diamond is true, the flow goes round again; when it becomes false, the other exit leaves the loop.
What is pseudocode?
Pseudocode is a plan for a program written in structured plain English, one step per line, using keywords such as INPUT, OUTPUT, IF, ELSE and WHILE and indentation to show structure. It ignores the exact syntax of any programming language.
What is the difference between a flowchart and pseudocode?
Both describe an algorithm before it is coded. A flowchart is a diagram of shapes connected by arrows; pseudocode is written text. Flowcharts make the flow of decisions and loops easy to see, while pseudocode is quicker to write and closer to real code.
What does IPO mean in programming?
Input, Processing, Output: a way to plan a program by listing what data comes in, what must be done to it, and what results go out. Inputs and outputs become parallelograms in a flowchart, and processing becomes rectangles and diamonds.
Something here not clear? A topic you wish we covered? Tell us. We read every message, and a request is the fastest way to get a guide written — several of these exist because somebody asked.