☰ خطة العام · تكنولوجيا المعلومات والاتصالات (بالإنجليزية)

Thinking like a computer

الأسبوع 1 · الدرس ١ «التفكير الحاسوبي وحل المشكلات» (١): المهارات الأربع وخطوات حل المشكلة ومثال جمع رقمين · 3 دروس
2

Five steps from problem to tested answer

ICT Prep 3 Term 1, Unit 1, Lesson 1: pp. 6–7
GoalPut the five steps of solving a problem in order and say which skill each step uses.
New words
input · the data given to a solution when it startsoutput · the result a solution shows or gives backcode · the algorithm written in a programming languagetesting · running the solution on cases whose answers you already know
Explanation

A problem becomes a working program in five steps. Step 1, understand the problem: say in your own words what is asked, and split it into parts. This uses decomposition. Step 2, find the inputs and the outputs: what do we start with, and what must we get? This uses abstraction, because only the important facts count. Step 3, write the steps, the algorithm; here pattern recognition helps if you solved a similar problem before. Step 4, turn the steps into code in a language such as Python. Step 5, test the solution on cases where you already know the answer. If a test fails, go back to the step where the slip began. The steps are not a one-way road: careful programmers return to an earlier step again and again.

Worked examples
StepWhat we write
1 Understandfind the cost of 3 notebooks
2 Inputs, outputprice, number; cost
3 Stepscost = price × number
5 Testprice 5, number 3 → 15
Problem: a shop sells notebooks at the same price each. How much do 3 notebooks cost? Step 1: find the total cost. Step 2: inputs are the price and the number of notebooks, the output is the cost. Step 3: multiply. Step 5: with a price of 5 and 3 notebooks the answer must be 15.
Sami wants his program to add 4 and 9, but the screen shows 5. The test failed. He reads his steps and sees that the code subtracts. He goes back to Step 4, changes the minus into a plus and tests again. Now the screen shows 13.
Class activity

Take the problem “find the area of a rectangular poster”. Write the five steps on paper: what is asked, the inputs and the output, the steps, and one test with numbers you choose. You do not need a device.

Practice
1
What is the first step in solving a problem?
2
In which step do we decide that a poster problem needs a length, a width and one result?
3
A test fails. What should you do?
4
Why do we test with numbers whose answer we already know?