Problem solving is finding an organised way to move from a problem statement to a working solution. In computer science, the final solution is usually a program, but the thinking work happens before any code is written.
Before learning Python syntax, we learn the thinking tools a programmer uses every day: algorithms, flowcharts, pseudocode, and decomposition. These tools work for any language, not just Python.
Every programming task moves through these five stages, in order. Skipping any one of them usually leads to bugs or wasted work.
| Step | What you do |
|---|---|
| 1. Analyse | Understand the problem — what are the inputs, outputs, and rules? |
| 2. Algorithm | Write a step-by-step plan in plain language. |
| 3. Coding | Translate the algorithm into a programming language. |
| 4. Testing | Run the program with sample inputs and check the output. |
| 5. Debugging | If the output is wrong, find the cause and fix it. |
An algorithm is a finite sequence of well-defined steps that solves a problem. It must finish, must produce a result, and must work for every valid input.
| Property | Meaning |
|---|---|
| Finiteness | Ends after a limited number of steps. |
| Definiteness | Each step is clear and unambiguous. |
| Input | Takes zero or more well-defined inputs. |
| Output | Produces at least one output. |
| Effectiveness | Each step can actually be carried out. |
A flowchart is a picture of an algorithm drawn with standard shapes connected by arrows. The shape tells you the kind of step, and the arrow tells you the order.
| Shape | Used for |
|---|---|
| Oval (terminator) | Start / Stop of the flow |
| Parallelogram | Input or Output (READ / PRINT) |
| Rectangle | Process (calculation, assignment) |
| Diamond | Decision (Yes/No question) |
| Arrow | Direction of the flow |
+--------+ +-----------+ +-----------+ +---------+ +-------+ | Start |->| Read A, B |->| C = A + B |->| Print C |->| Stop | +--------+ +-----------+ +-----------+ +---------+ +-------+Three rectangles + two ovals + arrows. No decision is needed because the flow is purely sequential.
Start -> Read m -> < m >= 33? >
/ \
Yes No
v v
Print "Pass" Print "Fail"
\ /
\ /
v v
Stop
The diamond < m >= 33? > branches the flow into two paths. Both paths meet again at the Stop oval.Yes (or True) and one labelled No (or False). Forgetting one of the labels is a common mistake.Pseudocode is an algorithm written in plain English with a few programming-style words. It is not a real language — the computer cannot run it — but it sits between the algorithm and the actual code.
BEGIN
READ a, b, c
SET avg = (a + b + c) / 3
PRINT avg
END
Five lines — one start, one input, one process, one output, one stop.BEGIN
READ marks
IF marks >= 33 THEN
PRINT "Pass"
ELSE
PRINT "Fail"
ENDIF
END
Indentation under IF / ELSE makes the two branches obvious to the reader.BEGIN
READ n
SET total = 0
FOR i = 1 TO n DO
total = total + i
ENDFOR
PRINT total
END| Flowchart | Pseudocode |
|---|---|
| Picture — visual | Text — closer to code |
| Best for short logic | Best for long algorithms |
| Easy for non-coders | Easy to translate to a real language |
| Hard to edit on paper | Easy to edit / version-control |
END (or ENDIF / ENDWHILE / ENDFOR) at the close of a block.ELSE — ELSE never has a condition.marks or total.Decomposition means splitting a big problem into smaller sub-problems. Each sub-problem is easier to plan, code, and test than the whole.
A useful rule is the "one sentence" test: if you can describe what a sub-problem does in one short sentence, it is small enough. If you need "and… and… and…", split it again.
| Description (one sentence) | Verdict |
|---|---|
| "Calculate the percentage." | Good size |
| "Read marks, find total, find %, decide grade, print." | Too big — split |
| "Print a header line." | Good size |
SET a = 6, b = 9 PRINT a + bOutput:
SET x = 10 IF x > 0 THEN PRINT "+ve" ELSE PRINT "-ve" ENDIFOutput:
FOR i = 1 TO 3 DO PRINT i * 10 ENDFOROutput:
SET total = 0 FOR i = 1 TO 4 DO total = total + i ENDFOR PRINT totalOutput:
SET marks = 75 IF marks >= 33 THEN PRINT "Pass" ELSE PRINT "Fail" ENDIFOutput:
SET a = 5, b = 12 IF a > b THEN PRINT a ELSE PRINT b ENDIFOutput:
SET n = 4 WHILE n > 0 DO PRINT n n = n - 1 ENDWHILEOutput:
SET p = 2, count = 0 WHILE p < 30 DO p = p * 2 count = count + 1 ENDWHILE PRINT countOutput:
Each pseudocode has exactly one error. Mark the line number and write the correction.
1 BEGIN 2 SET total = a + b 3 PRINT total 4 ENDWrong line: Correction:
1 BEGIN
2 READ x
3 IF x > 0 THEN
4 PRINT "+ve"
5 END
Wrong line: Correction: 1 BEGIN 2 READ a, b 3 IF a > b 4 PRINT a 5 ENDIF 6 ENDWrong line: Correction:
1 BEGIN 2 SET n = 5 3 WHILE n > 0 DO 4 PRINT n 5 ENDWHILE 6 ENDWrong line: Correction:
1 BEGIN 2 READ marks 3 IF marks >= 33 THEN 4 PRINT "Pass" 5 ELSE marks < 33 6 PRINT "Fail" 7 ENDIF 8 ENDWrong line: Correction:
1 BEGIN 2 SET sum = 0 3 FOR i = 1 TO 5 4 sum = sum + i 5 ENDFOR 6 PRINT sum 7 ENDWrong line: Correction:
Use a separate sheet for flowchart drawings if you need more space. Pseudocode answers may use BEGIN/END, READ, PRINT, IF/ELSE, WHILE/FOR.