Last updated: 4 December 2026 · Punjab Board 9th Class Computer Science and Entrepreneurship (new syllabus 2025-26) · Unit 7
Easy, exam-focused notes for Unit 7: Computational Thinking of the new Punjab Board 9th class Computer Science book. Short answers are written to fit the board e-sheet answer space. All exercise MCQs are checked against the textbook answer key.
In this unit
- Computational thinking and its 4 components
- Principles of computational thinking
- Flowcharts and symbols
- Pseudocode with examples
- Time and space complexity
- Dry run and simulation
- LARP
- Errors and debugging
- Exercise: MCQs, short and long questions
- FAQs
7.1 Computational thinking (CT)
Computational thinking is a problem-solving approach that uses a set of skills to solve complex problems in a way a computer could carry out. It is useful in every field – science, maths and daily life (planning a trip, organising tasks).
| Component | Meaning | Example |
|---|---|---|
| Decomposition | Breaking a big problem into smaller, manageable parts | Building a birdhouse: design → gather materials → cut wood → assemble → paint → install |
| Pattern recognition | Finding similarities or regularities | Area of squares 1, 4, 9, 16 … = sums of odd numbers (1, 1+3, 1+3+5 …) |
| Abstraction | Hiding unnecessary details and keeping only the essential ones | Making tea: boil water → add tea → steep → pour (ignore brand of kettle, etc.) |
| Algorithm | A step-by-step set of instructions to solve a problem | A cake recipe; steps to plant a tree |
7.2 Principles of computational thinking
- Problem understanding – the first and most important step: find the core issue, requirements and goals. It gives clarity, clear goals, efficient solutions and fewer mistakes. Example: before building a school website, list the pages needed, the users (students, teachers, parents) and the tools available.
- Problem simplification – break it into sub-problems (website: layout, content, coding).
- Solution selection and design – compare approaches, choose the most efficient one and make a detailed plan or algorithm.
7.3.1 Flowcharts
A flowchart is a diagram of the steps of a process using standard symbols joined by arrows. Benefits: clarity, communication, problem solving (finding bottlenecks) and documentation. Standard symbols were set by ANSI in 1947.
| Symbol | Name | Use |
|---|---|---|
| Oval | Terminal | Start / End |
| Rectangle | Process | A task or calculation, e.g. Sum = A + B |
| Parallelogram | Input / Output | Read input or display output |
| Diamond | Decision | Yes/No or True/False question |
| Arrow | Flowline | Direction of flow |
Example (shop order): Start → Get order → Item available? No → notify customer → End; Yes → pick, pack and ship → Customer pays? Yes → deliver, increase rating; No → bring item back, decrease rating → End.
7.3.2 Pseudocode
Pseudocode describes an algorithm in simple, structured English. It is not real code and cannot run, but it is easy to read and easy to turn into any programming language. Benefits: clarity, planning, communication.
Procedure CheckEvenOdd(number)
Begin
if (number % 2 == 0) then
print "Even"
else
print "Odd"
end if
End
Procedure IsPrime(number)
Begin
if (number <= 1) then return False
for i from 2 to sqrt(number) do
if (number % i == 0) then return False
end for
return True
End
We only check divisors up to √number, because any larger factor would pair with a smaller one already checked.
| Pseudocode | Flowchart |
|---|---|
| Plain, structured language | Graphical symbols and arrows |
| Read like a story, step by step | Seen like a picture of the whole flow |
| Easy to convert into code | Easy to see decisions at a glance |
| Better for detailed logic | Better for explaining to non-programmers |
7.4 Algorithm evaluation
- Time complexity: how the running time grows as the input grows (searching 10 vs 1,000 names). Written in Big O, e.g. O(n), O(log n), O(n²). Fewer steps = faster algorithm.
- Space complexity: how much memory the algorithm needs as input grows.
7.5 Dry run and simulation
A dry run means going through an algorithm by hand, step by step, with sample data to check that it works and to catch logical errors early.
FindMax: Input num1, num2 if num1 > num2 then max = num1 else max = num2 Output max Dry run (10, 15): 10 > 15? False → max = 15 → Output 15
Simulation uses a computer model of a real process to test ideas without real-life risk. Benefits: cheap, safe, repeatable. Examples: weather forecasting, city traffic planning.
7.6 LARP
LARP (Logic of Algorithms for Resolution of Problems) is software for learning algorithms by writing them as pseudocode or flowcharts and running them to see results. It helps students understand how algorithms work, see the effect of different inputs, and practise improving them. Its simple commands include START, END, WRITE (display), READ (input) and IF…THEN…ELSE…ENDIF.
START
WRITE "Enter a number"
READ number
IF number % 2 == 0 THEN
WRITE "The number is even"
ELSE
WRITE "The number is odd"
ENDIF
END
7.7 Errors and debugging
| Error | Meaning | Example |
|---|---|---|
| Syntax error | Wrong writing/symbol in the algorithm; easiest to find (LARP points it out) | Missing ENDIF or wrong symbol |
| Runtime error | Happens while running | Dividing by zero |
| Logical error | Runs but gives wrong answers; hardest to find | Using > instead of < in a decision |
- Debugging techniques: trace the steps, use comments, check conditions, simplify the problem and test parts separately. (The word comes from a real moth found inside an early computer.)
- Common LARP messages: Missing step, Undefined variable (used before being given a value), Invalid operation (e.g. divide by zero).
Unit 7 exercise (solved)
A. Multiple choice questions
1. Which of the following best defines computational thinking?
(a) A method of solving problems using mathematical calculations only (b) A problem-solving approach that employs systematic, algorithmic, and logical thinking (c) A technique used exclusively in computer programming (d) An approach that ignores real-world applications
Answer: (b) A problem-solving approach that employs systematic, algorithmic, and logical thinking – CT is used in every field, not only programming.
2. Why is problem decomposition important in computational thinking?
(a) It simplifies problems by breaking them down into smaller, more manageable parts (b) It complicates problems by adding more details (c) It eliminates the need for solving the problem (d) It is only useful for simple problems
Answer: (a) It simplifies problems by breaking them down into smaller, more manageable parts – Smaller parts are easier to solve.
3. Pattern recognition involves:
(a) Finding and using similarities within problems (b) Ignoring repetitive elements (c) Breaking problems into smaller pieces (d) Writing detailed algorithms
Answer: (a) Finding and using similarities within problems – Breaking into pieces is decomposition.
4. Which term refers to the process of ignoring the details to focus on the main idea?
(a) Decomposition (b) Pattern recognition (c) Abstraction (d) Algorithm design
Answer: (c) Abstraction – Abstraction keeps only essential details.
5. Which of the following is a principle of computational thinking?
(a) Ignoring problem understanding (b) Problem simplification (c) Avoiding solution design (d) Implementing random solutions
Answer: (b) Problem simplification – Others are the opposite of CT.
6. Algorithms are:
(a) Lists of data (b) Graphical representations (c) Step-by-step instructions for solving a problem (d) Repetitive patterns
Answer: (c) Step-by-step instructions for solving a problem – Graphical representation is a flowchart.
7. Which of the following is the first step in problem-solving according to computational thinking?
(a) Writing the solution (b) Understanding the problem (c) Designing a flowchart (d) Selecting a solution
Answer: (b) Understanding the problem – You must understand a problem before solving it.
8. Flowcharts are used to:
(a) Code a program (b) Represent algorithms graphically (c) Solve mathematical equations (d) Identify patterns
Answer: (b) Represent algorithms graphically – They are diagrams of algorithms.
9. Pseudocode is:
(a) A type of flowchart (b) A high-level description of an algorithm using plain language (c) A programming language (d) A debugging tool
Answer: (b) A high-level description of an algorithm using plain language – It cannot be run like real code.
10. Dry running a flowchart involves:
(a) Writing the code in a programming language (b) Testing the flowchart with sample data (c) Converting the flowchart into pseudocode (d) Ignoring the flowchart details
Answer: (b) Testing the flowchart with sample data – It is done by hand with sample values.
B. Short questions
C. Long questions
START
WRITE "Enter marks"
READ marks
IF marks >= 90 THEN
WRITE "Grade A+"
ELSE IF marks >= 80 THEN
WRITE "Grade A"
ELSE IF marks >= 70 THEN
WRITE "Grade B"
ELSE IF marks >= 60 THEN
WRITE "Grade C"
ELSE
WRITE "Grade F"
ENDIF
END
Dry run: marks = 76 → not >= 90, not >= 80, >= 70 True → "Grade B"
Flowchart: Start (oval) → Input marks (parallelogram) → diamond “marks ≥ 90?” Yes → Output A+; No → diamond “≥ 80?” Yes → A; No → “≥ 70?” → B; No → “≥ 60?” → C; No → F → End.
- Understand and decompose the problem (e.g. a shop order system: order, stock check, payment, delivery, rating).
- Draw a flowchart to see the decisions (item available? customer pays?).
- Write pseudocode for each part in detail.
- Dry run with sample orders, fix errors, then code it.
- Definition as above; four components.
- Medicine: finding patterns in symptoms. Weather: simulations to forecast. Daily life: planning a trip or study timetable. Business: processing orders efficiently.
- Flowchart + visual, easy for beginners and non-programmers; – large ones get messy, hard to change.
- Pseudocode + quick to write and edit, close to code; – less visual, no fixed standard.
- Use a flowchart to explain a process to a team; use pseudocode before coding a program.
9th class computer unit 7 MCQs with answers
Unit 7 (Computational Thinking) exercise MCQ answers: 1-b, 2-a, 3-a, 4-c, 5-b, 6-c, 7-b, 8-b, 9-b, 10-b.
What are the 4 components of computational thinking?
Decomposition, pattern recognition, abstraction and algorithms.
What are flowchart symbols?
Oval (start/end), rectangle (process), parallelogram (input/output), diamond (decision) and arrow (flow line).
What is LARP in computer science 9th class?
LARP stands for Logic of Algorithms for Resolution of Problems; it is software to write and run pseudocode and flowcharts.
Types of errors in algorithms
Syntax errors, runtime errors (e.g. divide by zero) and logical errors (wrong results).
📄 Download these notes as PDF
Save this chapter to your phone or computer and read it offline, or share it with your friends.
The PDF downloads directly. Long chapters may take a few seconds.
More 9th Class Computer Science
Need a Computer Science home tutor?
Male & female Computer Science tutors in all major cities of Pakistan, home or online. 3-day free demo.
