Units — Computer Education — Class 7
  1. Unit 1ICT Fundamentals
  2. Unit 2Digital Skills
  3. Unit 3Algorithmic Thinking and Problem Solving
  4. Unit 4Programming
  5. Unit 5Digital Citizenship
  6. Unit 6Entrepreneurship

Unit 3: Algorithmic Thinking and Problem Solving

Read the complete lesson, check the fully solved exercises, then test yourself with the MCQs quiz. Teachers get a complete guide with this unit.

Sindh Textbook Board50 MCQs5 Practice Sets

Computer Education — Class 7 · Unit 3 · Printed pages 78–104

Source: The Textbook of Computer Education for Class VII, Sindh Textbook Board, Jamshoro.

About this source

Textbook text is reproduced for free educational study. All solutions, explanations, practice questions, diagrams and teacher's guides are original work by 100MCQs. 100MCQs is an independent site and is not affiliated with or endorsed by the Sindh Textbook Board. Read our Disclaimer.

📖 Lesson — Algorithmic Thinking and Problem Solving

Below is the complete lesson of Unit 3 from the textbook (printed pages 78–104), in the book's own order. Read it fully — important words are bold. Inside the parts you will find word boxes: 📚 Book Vocabulary (the book's own words, marked ⭐) and 🌱 Extra Help Words. Where the book prints something that needs a correction or a caution, a note keeps the book's words and explains openly.

📖 Lesson — Algorithmic Thinking and Problem Solving

Below is the complete lesson of Unit 3 from the textbook (printed pages 78–104), in the book's own order. Read it fully — important words are bold. After every part you will find two word boxes: 📚 Book Vocabulary (the book's own words, marked ⭐) and 🌱 Extra Help Words. Where the book prints something that is wrong, a note keeps the book's words and gives the correction openly.

Part 1 — Computational Thinking (printed pp 78–79)

Introduction to the Unit. This chapter introduces algorithmic thinking to solve complex problems. In this chapter, we will learn how to think like a computer scientist by applying computational thinking to solve problems in a smart and organized way. This chapter also covers how to design algorithms and flowcharts for solving different problems using algorithmic notations.

Student Learning Outcomes (printed p 78). After the completion of this unit students will be able to:

  • Solve complex problems by applying computational thinking.
  • Understand different steps of computational thinking to solve a complex problem.
  • Define algorithms and provide simple real-life examples of algorithms.
  • Design algorithms for complex problems.
  • Draw flowcharts for representing algorithms.
  • Understand control structures including conditions and loops.
  • Apply conditions and loops for designing algorithms.
  • Infer clear instructions to produce correct results.
  • Analyze different ways to solve the same problem.
  • Understand and validate the algorithms to solve the problem.

3.1 Computational Thinking. Computational thinking helps to solve big problems step by step. It works like a computer. Its key steps:

  1. Break it down – Split big problems into small parts.
  2. Ignore extras – Remove things that don't matter.
  3. Plan clearly – Make a smart step-by-step solution.

Example: Planning a school trip. Break: (Step 1) Pack bag, (Step 2) board bus, reach school. Ignore: Weather forecast (not needed now). Plan: Step 1 → Step 2 → Done.

DO YOU KNOW?

  • A simple problem is one that can be solved in two to three easy steps. Example: Tying shoelaces or solving 5 + 3.
  • A complex problem needs more steps, planning, and decisions. Example: Organizing a school event.

Computational thinking is comprised of four important skills, shown in the book's Figure 3.1:

SkillWhat it means
DecompositionBreaking down a problem into smaller parts which are easier to solve.
AbstractionIdentifying only the important details of a problem and ignoring the rest.
Logical ThinkingSolving a given problem step-by-step in a clear and organized way — making a clear plan.
Decision MakingSelecting the best solution among different options.

📚 Book Vocabulary — Words in this part

computational thinking — Thinking like a computer scientist: solving a problem in a smart, organised, step-by-step way. ⭐Book word

simple problem — A problem that can be solved in two to three easy steps, e.g. tying shoelaces or solving 5 + 3. ⭐Book word

complex problem — A problem that needs more steps, planning and decisions, e.g. organising a school event. ⭐Book word

🌱 Extra Help Words — Words in this part

sequence — Things following one after another in a fixed order.

Part 2 — Applying Computational Thinking: the Clean and Green Pakistan Day (printed p 80)

3.1.1 Applying Computation Thinking to Solve Complex Problems. Consider a problem to organize an event "Clean and Green Pakistan Day". Students will clean classrooms. They will plant trees. They will spread awareness to keep Pakistan clean. This is a complex problem. It needs computational thinking to solve it. Break it into small steps.

Steps of Computational Thinking:

  1. Understand the Problem – What needs to happen? Who joins? When and where?
  2. Break It Down – Split into parts: Planning, cleaning, planting, awareness.
  3. Find Patterns – Reuse ideas, like group teams for all tasks.
  4. Ignore Extras – Skip things not needed, like fancy decorations.
  5. Make a Plan – Step-by-step: Invite people, get tools, do the event, check results.

1. Decomposition. Breaking a big or complex problem into smaller manageable tasks. For example, organizing an event "Clean Pakistan Day". The smaller manageable tasks may include: prepare a task list; register volunteers for each task; prepare a list of equipment for each task; choose team leads; set day and time of each event.

Example Plan: Step 1: List supplies (brooms, seeds, posters). Step 2: Assign jobs (Group A cleans, Group B plants). Step 3: Practice speeches for awareness. Step 4: Hold the event and clean up.

📚 Book Vocabulary — Words in this part

decomposition — Breaking down a problem into smaller parts which are easier to solve. ⭐Book word

Part 3 — Abstraction and Logical Thinking (printed p 81)

2. Abstraction means: ignore things that do not help; focus on only important details.

Important (Keep)Irrelevant (Ignore)
Number of volunteersColor of their shirts
Number of trees to plantBrand of planting tools
Cleaning areas (classrooms)Shape of the dustbins
Date and timeWeather next week
Items for safety (gloves and masks)Brand of masks
Getting permission from school—

Abstraction helps to 1) save time, 2) keep plan simple, and 3) helps to finish task quickly.

3. Logical Thinking. Make a clear and simple plan. Event Plan — Clean and Green Pakistan Day:

  1. Get permission — Ask the principal to approve the event.
  2. Make volunteer groups — Cleaning Group (clean classrooms), Planting Group (plant trees), Awareness Group (make and paste posters).
  3. Arrange materials — Brooms, gloves, saplings, paper, colors.
  4. Set date and time — Friday, 8:00 AM to 12:00 PM.

Example: Step 1: Principal says YES. Step 2: 10 students in Cleaning Group. Step 3: Buy 20 trees. Step 4: Event on Friday at 8 AM.

📚 Book Vocabulary — Words in this part

abstraction — Ignoring irrelevant information and focusing on only the important details of a problem. ⭐Book word

logical thinking — Making a clear and organised plan of what to do, and in what order. ⭐Book word

Part 4 — Decision Making (printed p 82)

4. Decision Making. Good choices help the event succeed — even with problems/challenges.

Challenge FacedSmart Decision
Low budgetChoose cheap plants (like local seeds)
Few volunteersJoin two groups into one
Rain comingMove event inside or pick a new date

Example: Rain forecast? Hold poster-making in the hall. Only 5 helpers? One team cleans and plants. Note: Think fast, act smart — every problem has a fix.

📚 Book Vocabulary — Words in this part

decision making — The process of making smart and good decisions in the presence of challenging situations. ⭐Book word

Part 5 — What is an Algorithm? (printed pp 82–83)

3.2 Algorithm. An algorithm is a step-by-step plan to solve a problem. It is a well-defined and finite sequence of instructions to solve a problem or perform a specific task. Everyday Life Examples: following a cake recipe; solving a math problem step by step.

Problem: A customer buys a Mouse at Rs. 500, Keyboard at Rs. 1200 and Watch at Rs. 800. Find the total amount to pay.

ALGORITHM (STEP-BY-STEP)

  1. Start
  2. Write price of mouse = 500
  3. Write price of keyboard = 1200
  4. Write price of watch = 800
  5. Add all prices: 500 + 1200 + 800
  6. Total = 2500
  7. Stop

Total Amount: Customer pays Rs 2500. (Trace it: 500 + 1200 = 1700, and 1700 + 800 = 2500. Remember this total — the validation example on printed page 98 uses these same prices.)

The same algorithm can be written with variables. Algorithm: To calculate total price paid by a customer on buying three products. Step-1: Input price of mouse, 'P1'. Step-2: Input price of keyboard, 'P2'. Step-3: Input price of watch, 'P3'. Step-4: Calculate total price, Price = P1 + P2 + P3. Step-5: Print Total Price. Step-6: End.

Let's say: Price of mouse = Rs. 100; Price of keyboard = Rs. 250; Price of watch = Rs. 200. Total Price = 100 + 250 + 200 = Rs. 550. Thus customer pays Rs. 550 as total price.

📚 Book Vocabulary — Words in this part

algorithm — A well-defined and finite sequence of instructions to solve a problem or perform a specific task. ⭐Book word

🌱 Extra Help Words — Words in this part

instruction — A single order that tells a computer or robot exactly one thing to do.

input — The data given to an algorithm for it to work on, e.g. the marks of a subject.

Part 6 — Flowcharts and Their Symbols (printed p 83)

3.3 Flow Charts. A flowchart is a graphical representation of an algorithm. Table 3.1 shows commonly used symbols for drawing flowcharts along with their description:

ShapeNamePurposeExample
OvalTerminatorShows Start or End of a flowchartStart, End
ParallelogramInput / OutputUsed for taking input or showing outputInput number, Display result
RectangleProcess / ActionRepresents a process or step to performAdd 2 numbers, Calculate area
DiamondDecisionRepresents a decision or conditionIs number > 0?, Is it raining?
ArrowFlowline / ArrowShows direction of flowConnects symbols to show sequence

📚 Book Vocabulary — Words in this part

flowchart — A graphical (diagram) representation of an algorithm. ⭐Book word

oval (terminator) — The flowchart symbol that shows the Start or End of a flowchart. ⭐Book word

parallelogram (input/output) — The flowchart symbol used for taking input or showing output. ⭐Book word

rectangle (process) — The flowchart symbol that represents a process or a step to perform. ⭐Book word

diamond (decision) — The flowchart symbol that represents a decision or condition. ⭐Book word

flowline — The arrow symbol that connects flowchart symbols to show the flow (sequence) of the algorithm. ⭐Book word

🌱 Extra Help Words — Words in this part

output — The result an algorithm produces and shows, e.g. "You are Pass".

Part 7 — Control Structures and the IF Statement (printed p 84)

3.4 Control Structures for Writing Algorithms. Control structures are building blocks of algorithms. There are two main types of control structures: Conditions and Loops/Iteration. This section will explore how these control structures can be applied to solve complex problems.

3.4.1 Conditions. Sometimes, a user wants to choose different actions based on different situations. Conditions allow algorithms to make choices. For example: If it rains today, then I will take umbrella. If it is holiday, I will not go to school. Otherwise, I will go to school. If the password is correct, allow login.

i) If Statement. This statement gives only one choice. If the condition is true then it will take some action, otherwise it will skip the action. For example, if today is a holiday I will not go to school.

ALGORITHM: TO CHECK IF YOU ARE PASS IN A SUBJECT

  1. Start
  2. Input marks of a subject, Marks
  3. If Marks >= 50, then:
  4. Print "You are Pass"
  5. End

The flowchart in words: Start → Print "Input Marks of a Subject", Marks → If Marks >= 50? — Yes → Print "You are Pass" → Stop; — No → go straight to Stop. In this algorithm, if the given condition Marks >= 50 becomes true, only then will it take an action, to display "You are Pass". Otherwise, no action is performed when the condition is false.

📚 Book Vocabulary — Words in this part

control structure — A building block of an algorithm that controls the order of steps; the two main types are conditions and loops. ⭐Book word

condition — A check that lets an algorithm make a choice, e.g. "If Marks >= 50". ⭐Book word

if statement — A conditional statement that takes an action only if its condition is true; otherwise it does nothing. ⭐Book word

🌱 Extra Help Words — Words in this part

branch — A path an algorithm can take when a condition sends the flow one way or another.

Part 8 — The If-Else Statement (printed p 85)

ii) If-Else Statement. This statement gives two choices: if the given condition is true it takes an action, but when the condition is false it takes an alternative action. For example: if you obtain 50 marks then you are pass, otherwise you are fail.

ALGORITHM: TO CHECK IF YOU ARE PASS OR FAIL IN A SUBJECT

  1. Start
  2. Input marks of the subject, Marks
  3. If Marks >= 50, then:
  4. Print "You are Pass"
  5. Else:
  6. Print "You are Fail".
  7. End

The flowchart in words: Start → Print "Input Marks of a Subject", Marks → If Marks >= 50? — Yes → Print "You are Pass" → Stop; — No → Print "You are Fail" → Stop. When the given condition Marks >= 50 is true, it takes an action (Print Pass). When the condition is false it takes another action (Print Fail).

📚 Book Vocabulary — Words in this part

if-else statement — A conditional statement that takes one action if the condition is true and another action if it is false. ⭐Book word

Part 9 — The If-ElseIf-Else Statement (printed p 86)

iii) If-ElseIf-Else Statement. The If-ElseIf-Else statement allows us to check multiple conditions. The computer will check all conditions in a given order, and it only runs the one that is true. For example: If your marks are above 80, you get Grade A. Else If marks are above 60, you get Grade B. Else If marks are above 50, you get Grade C. Else, you are Fail.

ALGORITHM: TO CHECK WHICH GRADE IS OBTAINED

  1. Start
  2. Input marks of a subject, Marks
  3. If Marks > 80, then:
  4. Print "Grade-A"
  5. Else If Marks > 60, then:
  6. Print "Grade-B".
  7. Else If Marks > 50, then:
  8. Print "Grade-C".
  9. Else
  10. Print "You are Fail".

The flowchart in words: Start → Input Marks → If Marks > 80? — Yes → Print "Grade A" → Stop; — No → If Marks > 60? — Yes → Print "Grade B" → Stop; — No → If Marks > 50? — Yes → Print "Grade C" → Stop; — No → Print "You are Fail" → Stop.

Trace it: Marks = 65 → not above 80 → above 60 ✓ → Grade B. Marks = 50 → not above 80, 60 or 50 (the book says "above", not "equal to") → You are Fail. Notice the difference from the pass/fail algorithm, where Marks >= 50 means exactly 50 is a Pass.

📚 Book Vocabulary — Words in this part

if-elseif-else statement — A conditional statement that checks multiple conditions in order and runs only the first one that is true. ⭐Book word

Part 10 — Finite Loops (printed pp 87–88)

3.4.2 Loops/Iteration. Imagine giving instructions to a robot to perform the same action over and over again. For example, 'clap your hands', 'clap your hands', 'clap your hands'…". This repetition is called a loop.

i) Finite Loops. A finite loop is a set of instructions that repeats for a fixed number of times, and then it stops. It always has a clear end point. For example: taking input of five numbers from user; clapping 10 times; doing fifteen push-ups, etc. A finite loop is used in two situations: 1) Knowing exactly how many times to repeat. For example: we do homework 3 times. 2) Not knowing exactly how many times to repeat but the task is repeated until some goal is achieved. For example: we brush our teeth until they get clean.

ALGORITHM-1: DISPLAY EVEN NUMBERS FROM 2 TO 10

  1. Start
  2. Repeat step 3 and 4 for Counter = 2 to 10
  3. Print Counter
  4. Increase Counter by 2
  5. End

The flowchart in words (printed p 88): Start → Set Counter = 2 → Is Counter <= 10? — Yes → Print Counter → Set Counter = Counter + 2 → back to the question; — No → Stop.

Trace it: Counter = 2 → print 2 → Counter = 4 → print 4 → 6 → print 6 → 8 → print 8 → 10 → print 10 → Counter = 12 → 12 <= 10 is false → Stop. Output: 2, 4, 6, 8, 10. It is known that the loop will repeat for a fixed number of times.

📚 Book Vocabulary — Words in this part

loop (iteration) — A control structure that repeats a set of instructions. ⭐Book word

finite loop — A set of instructions that repeats a certain number of times, or until its goal is achieved, and then stops. ⭐Book word

counter — A value used to keep count of how many times a loop has repeated, e.g. Counter in the even-number flowchart. ⭐Book word

🌱 Extra Help Words — Words in this part

value — A single piece of data, such as a number or a piece of text.

Part 11 — Finite Loop Example: Printing a Sentence Three Times (printed p 89)

ALGORITHM-2: TO DISPLAY A SENTENCE THREE TIMES ON SCREEN

  1. Start
  2. Set Counter = 1
  3. Repeat steps 4 to 6
  4. Display "Long Live Pakistan"
  5. Increase Counter by 1
  6. Until Counter > 3
  7. End

The flowchart in words: Start → Set Counter = 1 → Print "Long Live Pakistan" → Set Counter = Counter + 1 → Is Counter <= 3? — Yes → back to Print; — No → Stop.

Trace it: This algorithm will repeat exactly three times and each time it will print "Long Live Pakistan". When Counter becomes greater than 3, the loop stops. (Counter is 1, 2, 3 for the three prints; after the third print Counter becomes 4, and 4 <= 3 is false.)

🌱 Extra Help Words — Words in this part

variable — A named store for a value that can change while an algorithm runs, e.g. Counter or Marks.

Part 12 — Infinite Loops (printed pp 90–91)

ii) Infinite Loops. Infinite loops are tasks which keep on repeating over and over and never stop. For example: heart beating; monitoring by a security camera, etc. An infinite loop describes a series of instructions that repeats forever or until someone stops them.

ALGORITHM-1: KEEP BLINKING AN LED LIGHT

  1. Start
  2. Repeat steps 3 to 6 Forever:
  3. Turn LED ON.
  4. Wait 1 second.
  5. Turn LED OFF.
  6. Wait 1 second.

The flowchart in words: Start → Turn LED ON → Wait for 1 second → Turn LED OFF → Wait for 1 second → (line labelled "Repeat") back to Turn LED ON. In this algorithm, the steps inside the loop (steps 3 to 6) will keep repeating forever unless manually stopped (e.g., turning off the device).

ALGORITHM-2: TO CHECK TEMPERATURE

  1. Start
  2. Repeat Steps 3 to 5
  3. Input temperature through sensor
  4. Print temperature
  5. Wait 5 seconds
  6. End Repeat
  7. End

The flowchart in words (printed p 91): Start → Is condition true? — Yes → Read temperature sensor value → Print temperature → Wait for 5 second → back to the question; — No → Stop. This algorithm will keep on taking input of temperature forever (while its condition stays true).

Print note (printed p 91): the book's printed step algorithm (Algorithm-2) contains no condition or stop test at all — it repeats Steps 3 to 5, and the book's own callout beside it says it “will keep on taking input of temperature forever”. The “Is condition true?” test and the Stop appear only in the printed flowchart; the flowchart's version is the one taught above.

📚 Book Vocabulary — Words in this part

infinite loop — A series of instructions that repeats forever, or until someone stops it. ⭐Book word

Part 13 — Using Loops and Conditions: the Robot That Waters Plants (printed pp 91–92)

3.5 Using Loops and Conditions for Designing Algorithms. By understanding, breaking down, and planning, you can solve any complex problem with a clear algorithm. Examples of Complex Problems: 1. Finding the shortest path to school during traffic. 2. Planning a study schedule for exams. 3. Sorting 100 books in the library by name. 4. Programming a robot to water plants.

Robot Watering Algorithm (Example). Problem: Plants are in a straight line. Each has a moisture sensor. The robot must water only dry plants and skip wet ones.

ALGORITHM (STEP-BY-STEP)

  1. Start at the first plant
  2. Check moisture sensor
  3. If low → Pour water
  4. If normal → Skip
  5. Move to the next plant
  6. Repeat until the last plant
  7. Stop

Example Run/Execution:

PlantMoistureAction
1LowWater
2NormalSkip
3LowWater
4NormalSkip

The book also writes this algorithm with a while loop and a counter. Algorithm: A robot waters a plant if moisture level is low, otherwise move to the next plant. Step 1: Start. Step 2: Set PlantCounter = 1. Step 3: Set TotalPlants = N. Step 4: while (PlantCounter <= TotalPlants) Do — (a) Read Moisture level of current plant; (b) If moisture level is low, then water Plant; (c) Set PlantCounter = PlantCounter + 1. Step 5: End While. Step 6: End.

Trace the while algorithm with the run table above (N = 4): PlantCounter = 1 → plant 1 is Low → water → counter 2 → plant 2 is Normal → no water → counter 3 → plant 3 is Low → water → counter 4 → plant 4 is Normal → counter 5 → 5 <= 4 is false → End. Every plant is checked exactly once. Remember this correct behaviour — it is the standard the flowchart on the next printed page must match. This problem is complex because it involves making a smart decision based on moisture level, and it shows involvement of input from the environment (moisture level from sensor).

📚 Book Vocabulary — Words in this part

moisture sensor — A sensor that measures how wet or dry something is; in the example it tells the robot whether a plant needs water. ⭐Book word

🌱 Extra Help Words — Words in this part

notation — A standard way of writing something, e.g. the symbols and short forms used in algorithms and flowcharts.

Part 14 — The Robot Flowchart, Checked Carefully (printed p 93)

The book prints a flowchart for the robot algorithm on page 93. As printed, it reads: Start → Set PlantCounter = 1 → Set TotalPlants = N → Is PlantCounter > TotalPlants? — the No exit runs to Stop, and the Yes exit runs down to Read Moisture Level of current plant → Is Moisture Level Low? — Yes → Water Plant → Set PlantCounter = PlantCounter + 1 → back to the first question; — No → straight back to the first question.

Textbook correction (printed p 93): We traced this flowchart by hand, and as printed it does not work. It has two mistakes. Mistake 1 — the Yes/No exits of the first decision are swapped. At the start PlantCounter = 1, which is NOT greater than TotalPlants, so the printed chart takes the "No" exit — straight to Stop. The robot stops before checking even one plant. (And if the answer were ever Yes, it would try to read a plant that does not exist.) Mistake 2 — the skip path forgets to count. When a plant is skipped (moisture not low), the printed flow returns to the first question without adding 1 to PlantCounter, so the robot would re-check the same wet plant forever and never reach the later plants. The step-by-step algorithm on printed page 92 is correct — only this flowchart drawing is wrong. The corrected flowchart is given below.

The corrected flowchart (drawn by 100MCQs from the book's own correct algorithm on page 92): the first decision sends the robot to Stop only when PlantCounter has passed the last plant, and PlantCounter increases by 1 after every plant — watered or skipped.

StartSet PlantCounter = 1Set TotalPlants = NIs PlantCounter> TotalPlants?YesStopNoRead Moisture Levelof current plantIs MoistureLevel Low?YesWater PlantNoSet PlantCounter = PlantCounter + 1Corrected flow: every plant is checked once;the counter increases after watering AND after skipping.

Text alternative for the corrected flowchart: Start → Set PlantCounter = 1 → Set TotalPlants = N → Is PlantCounter > TotalPlants? — Yes → Stop. — No → Read Moisture Level of current plant → Is Moisture Level Low? — Yes → Water Plant → Set PlantCounter = PlantCounter + 1 → back to the first question. — No → Set PlantCounter = PlantCounter + 1 → back to the first question.

Part 15 — Inferring Clear Instructions (printed pp 93–94)

3.6 Inferring Clear Instructions. An algorithm must have clear steps. A computer follows them exactly. If steps are confusing, the result will be wrong. Imagine: Wali tells a robot to build a LEGO car. If his instructions are not clear, the robot may build a boat or plane instead.

Rules for Clear Algorithm Instructions: Use simple words — say "pick red brick" not "select crimson piece". Give one step at a time — don't mix actions. Be exact — say "place 2 wheels on left side" not "add some wheels". List steps in order — Step 1, Step 2, Step 3… Check the result — make sure the car moves and has 4 wheels.

Example: Build a LEGO Car (Clear Steps). 1. Take a yellow base plate (4×8). 2. Attach 2 black wheels to the back. 3. Attach 2 black wheels to the front. 4. Place a red seat in the middle. 5. Add a blue steering wheel. 6. Done — Wali has a car.

Rule-1: Be Specific and Do Not Guess. Computers don't think like humans. They follow only what a person tells. They cannot guess. Bad Instruction (Unclear) Example: "Make a red car." Problem with Bad Instruction: 1. Which part is red? 2. How much red? 3. Robot might make only wheels red or everything green! Good Instruction (Clear) Example: 1. Take four 2×4 red LEGO bricks. 2. Attach one red 2×4 brick on top of each black 2×2 wheel base. Result: Robot builds the correct red car body every time.

Rule-2: Break Down the Instructions into Smaller Steps. Always try to break big tasks into smaller easy-to-follow tasks. For example, if a robot has to build a LEGO car, then only the instruction "build car" is considered as too big. Instead: Step-1: Take one 5×10 gray colored base plate. Step-2: Take four black 3×3 wheel bases. Step-3: Attach one black 3×3 wheel base to each corner of the 5×10 gray base plate. Step-4: Take two 1×4 black axles. Step-5: Attach one axle to the front two wheel bases and one axle to the back two wheel bases. Step-6: Take four small black tires. Step-7: Attach one tire to each end of the axles.

🌱 Extra Help Words — Words in this part

step-by-step — Doing something one step at a time, in order, without skipping.

Part 16 — Rules 3, 4 and 5 for Clear Instructions (printed pp 95–96)

Rule-3: Clear Start and End Points. To write an algorithm, one should clearly specify where it starts and where it ends. (The book repeats the LEGO car steps, now numbered Step-1 "Start" to Step-9 "End".) Specifying "Start" and "End" makes it clear when an algorithm is active.

Rule-4: Specify Conditions Appropriately. While writing algorithms, one should clearly specify conditions; because sometimes, an algorithm needs to do different things depending on the situation. For example, to ask a robot to pick up a toy, one needs to clearly tell the robot what to do when a toy is not there. It should not get stuck if it cannot find a toy. Step-1: Start. Step-2: Look for a toy on floor. Step-3: If you see a toy, then: a. Move towards toy. b. Pick up toy. c. Carry toy to toy box. d. Put toy in toy box. Step-4: Else (if you do not see a toy), then: a. Look in a different spot. Step-5: If all toys are in toy box, then Stop. Step-6: Else (if there are still toys on the floor), then: a. Go back to step 1. The clear specifications of conditions help the robot to make smart decisions because it cannot make a guess.

Rule-5: Specify Loops Appropriately. Just like conditions, it is necessary to specify clearly when to repeat a task. For example, ask a robot to clean 3 tables. Simply say "keep wiping tables until there are no more dirty ones", instead of saying, "wipe table 1, wipe table 2, wipe table 3". Step-1: Start. Step-2: Go to first table. Step-3: Repeat if there are still dirty tables in row: a. Wipe down current table. b. Move to next table in row. Step-4: Goto Step-3. Step-5: End. Following these rules, a computer (robot) will be able to perform instructions perfectly and will produce correct results.

Part 17 — Activity: Clear and Unclear Instructions (printed p 96)

Activity Time. Analyze the given examples thoroughly and think why the instructions in the 3rd column of "Unclear Instructions" are not clear. (This activity is solved in the Solved Exercise tab.)

S#Example TaskClear InstructionsUnclear Instructions
1Checking if a Number is Even or Odd1. Start. 2. Input a number: N. 3. If N % 2 == 0, display "Even". 4. Else, display "Odd". 5. End.Take a number. Decide if it's even or odd. Show result.
2Finding Average of 3 Test Scores1. Start. 2. Input three test scores: score1, score2, score3. 3. Calculate total: total = score1 + score2 + score3. 4. Calculate average: average = total / 3. 5. Display average. 6. End.Get marks. Add them. Find average.

Part 18 — Different Ways to Solve the Same Problem (printed pp 96–97)

3.7 Different Ways to Solve Problem. One problem can have many solutions. Each algorithm may work differently but give the same correct answer. Problem: Check if a number is even or odd.

Algorithm 1: Using Division. 1. Take the number. 2. Divide by 2. 3. If remainder = 0 → Even. 4. Else → Odd. Example: Number = 8; 8 ÷ 2 = 4 (remainder 0) → Even.

MINOR PRINT SLIP (printed p 96): as printed, the example line reads “Number = 8 8 ÷ 2 = 4 (remainder 0) → Even” — the number 8 is printed twice. The intended working is the one shown above.

Algorithm 2: Using Last Digit. 1. Look at the last digit. 2. If it is 0, 2, 4, 6, or 8 → Even. 3. Else → Odd. Example: Number = 15; last digit = 5 → Odd.

Algorithm 3: Using Bit Check (Advanced). 1. Look at the least significant bit (LSB). 2. If LSB = 0 → Even. 3. If LSB = 1 → Odd. Example: Number = 10 (Binary: 1010); LSB = 0 → Even.

NumberAlgorithm 1Algorithm 2Algorithm 3Final Answer
77÷2 = 3 rem 1 → OddLast digit 7 → OddLSB = 1 → OddOdd
1212÷2 = 6 rem 0 → EvenLast digit 2 → EvenLSB = 0 → EvenEven

All three algorithms agree on both numbers — different ways, same correct answer.

📚 Book Vocabulary — Words in this part

remainder — What is left over after division, e.g. 7 ÷ 2 gives remainder 1. ⭐Book word

Part 19 — Two Methods in Detail (printed p 97)

Remainder check method: This method divides the given number by 2 and then checks for remainder value. If the remainder value is zero it means the number is even; otherwise, the number is odd.

SOLUTION-1: CHECK EVEN OR ODD USING "REMAINDER CHECK METHOD"

  1. Start
  2. Input number, Num
  3. If (Num % 2 == 0), then:
  4. Print num is even
  5. Else:
  6. Print: num is odd.
  7. End.

For example: if Num is 7, then 7÷2 is 3 with a remainder of 1. If remainder is not equal to 0, then Num (7) is odd. If Num is 8, then 8÷2 is 4 with a remainder of 0. If remainder is equal to 0, then Num (8) is even.

Look last digit method: This method is a simple way to check if a number is even or odd by only looking at its last digit. If the last digit is 0, 2, 4, 6 or 8, then the number is even. Otherwise, if the last digit is 1, 3, 5, 7, and 9, then it is an odd number.

Textbook correction (printed p 97): In the paragraph above, the book's printed sentence lists the even last digits as "0, 2, 4, 8" — the digit 6 is missing in that one sentence. The book's own Algorithm 2 (printed p 97) and Solution-2 below both include 6 ("0, 2, 4, 6, or 8"), and 6 is of course an even digit. Learn the full set: 0, 2, 4, 6, 8.

SOLUTION-2: CHECK EVEN OR ODD USING "LOOK LAST DIGIT METHOD"

  1. Start
  2. Input number, Num
  3. Look at the very last digit of Num
  4. If the last digit is 0, 2, 4, 6, or 8, then:
  5. Print num is even
  6. Else — if the last digit is 1, 3, 5, 7, or 9:
  7. Print: num is odd.
  8. End.

For example: if Num be 124, since the last digit of 124 is 4, 124 is Even. If Num be 7, since the last digit of 7 is 7, 7 is Odd.

📚 Book Vocabulary — Words in this part

least significant bit (LSB) — The last (right-most) bit of a binary number; if it is 0 the number is even, if it is 1 the number is odd. ⭐Book word

Part 20 — Understanding and Validation of Algorithms (printed p 98)

3.8 Understanding and Validation of Algorithms. Writing an algorithm is not enough. A person must understand it and check if it really works.

1. Understanding an Algorithm. It means: know what each step does; know why the step is needed; know how it helps solve the problem. If a person does not understand, then he/she may miss details and make mistakes.

2. Validating an Algorithm. It means: test if it gives correct results; try it with different inputs; see if output is right. If wrong → Fix the steps.

Key Terms in Validation:

TermMeaningExample
Statement / DataInput the algorithm getsNumbers, text, prices
Correct DataNormal inputs it should handleAge = 12, Name = "Ali"
Incorrect DataWrong or extreme inputsAge = −5, Name = "" (empty)
Determining OutputFollow each step with inputSee if total price = 2800 (as printed — see the correction note below)

Example: Test Total Price Algorithm. Algorithm: Add prices of mouse (500), keyboard (1200), watch (800).

Input TypeTest DataExpected Output (as printed)Result (as printed)
Correct500, 1200, 8002800☑ Pass
Incorrect−100, 1200, 800Should show error☑ Pass (if handles error)
Textbook correction (printed p 98): Add the test data yourself: 500 + 1200 + 800 = 2500, not 2800. The book's own total-price algorithm on printed page 82 also gives Total = 2500 for these same prices. So the printed value 2800 — used in the Key Terms table above and as the "Expected Output" in this test table — is wrong, and a correct algorithm would actually fail this test as printed — the book's test data, not the algorithm, has the mistake. When you validate an algorithm, the expected output must be calculated correctly first; here the correct expected output is 2500, and with that value the result really is a Pass. (The second row is fine: a negative price is incorrect data, and a good algorithm should show an error for it.)

📚 Book Vocabulary — Words in this part

validation — The process of checking if an algorithm really works as expected. ⭐Book word

correct data — The normal inputs an algorithm should handle, e.g. Age = 12, Name = "Ali". ⭐Book word

incorrect data — Wrong or extreme inputs used to test an algorithm, e.g. Age = −5. ⭐Book word

determining output — Following each step of an algorithm with a given input to see what output it produces. ⭐Book word

🌱 Extra Help Words — Words in this part

test data — Chosen example inputs used to check whether an algorithm works.

expected output — The correct result a test should produce if the algorithm is right.

dry run — Following an algorithm by hand with sample values to check what it does, before or instead of running it on a computer.

Part 21 — Testing with Cases, Summary and Terms to Remember (printed pp 99–100)

Example-1: Write an algorithm to check the age of a person for driving. Step-1: Start. Step-2: Input Age of person, Age. Step-3: If (Age >= 18), then: Step-4: Print: You are eligible to drive. Step-5: Else: Print: You are not eligible to drive. Step-6: End.

Now, do testing using different data values and see what output is produced by the above algorithm. To perform testing, consider following three different examples of data: Case-I: Age = 20 (it represents valid data). Case-II: Age = 17 (it represents valid data). Case-III: Age = −5 (it represents invalid data).

Trace the three cases: Age = 20 → 20 >= 18 ✓ → "You are eligible to drive". Age = 17 → 17 >= 18 ✗ → "You are not eligible to drive". Age = −5 → an age can never be negative, so this is invalid data — a well-built algorithm should reject it with an error instead of deciding about driving.

SUMMARY

  • Computational thinking is the foundation of writing algorithms to solve complex problems and is comprised of four important skills: Decomposition, Abstraction, Logical Thinking, and Decision Making.
  • Algorithm: A well-defined sequence of steps to solve a problem.
  • A flowchart shows visually steps required to complete a task and an order that is to be performed.
  • Conditions allow algorithms to make smart choices.
  • If conditional statement gives only one choice. If condition is true then it will take some action, otherwise it will do nothing.
  • If-Else statement gives two choices; if a given condition is true, it takes an action but if condition is false, it takes another action.
  • If-ElseIf-Else statement allows to check for multiple conditions.
  • Loop: A loop is an essential control structure that repeats a set of instructions.
  • A finite loop is a set of instructions that repeats a certain number of times, and then it stops.
  • An infinite loop describes a series of instructions that repeats forever or until someone stops them.
  • There can be more than one algorithm to solve a problem.

Terms to Remember: Complex Problem: Complex problems are those which have many parts, require smart thinking, and can be solved in more than one ways. Decomposition means to break down a problem into smaller manageable parts. Abstraction ignores irrelevant information and details of a problem to be solved. Logical thinking is creation of a clear and organized plan of what to do, and in what order. Decision making is a process of making smart and good decisions in presence of challenging situations. Validation: Validation is a process of checking if algorithm really works as expected.

Help us improve this page. Spotted a mistake, or something that is not clear? Email us at [email protected] — every report helps the next student.