Intro to Computer Science / Unit 3: Algorithms and Problem Solving
3.3 Pseudocode
Notes
Pseudocode is a plain-language way to describe an algorithm without worrying about exact programming syntax.
- Use clear action words: INPUT, SET, IF, ELSE, REPEAT, PRINT.
- Indent steps inside a decision or loop.
- Example (find the larger of two numbers):
INPUT a
INPUT b
IF a > b THEN
PRINT a
ELSE
PRINT b
- Pseudocode is for people. Python or another language is for the computer.
- Trace it: if a is 4 and b is 9, then a > b is false, so it prints 9.
Practice
What is pseudocode?
Pseudocode lets you plan logic without exact syntax.
In the pseudocode above, what is printed when a is 10 and b is 3?
10 > 3 is true, so the program prints a, which is 10.
Which pseudocode correctly describes finding the total of three numbers x, y and z?
The correct version adds all three values and displays the result.
Ready for more? Take the Unit 3 test.