AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

One step at a time

Week 25 · 4.2 Computer architecture · 3 lessons
1

Say exactly what to do

Computing 9: Topic 4.2, pp. 312–319
GoalExplain why the instructions given to a computer must be precise, detailed, in the right order and carried out one at a time.
New words
instruction · a command to do something, or a piece of information about how to do itprecise · exact and clear, with nothing left for the reader to guessprogram · a list of instructions for a computerprocessor · the part of the computer, the CPU, that follows the instructions
Explanation

People can follow a loose instruction because they fill the gaps with what they already know. “Tidy the desk” makes sense to a friend who knows your desk. A computer has no experience to use. It has only the instructions it is given at that moment. So every instruction must be precise: it says which thing, where and how much. A program also needs enough detail, because a step that is missing is a step that never happens. The steps must come in the right order, because a later step often needs the result of an earlier one. The processor then carries the steps out one at a time, like a person with only one pair of hands.

Loose instructionWhat a computer could not knowPrecise version
Water the plantwhich plant, and how much waterPour 200 ml of water into the pot on the left shelf
Add the numberswhich numbers, and where the answer goesAdd 7 and 5 and store the answer in total
Make it biggerwhich part, and by how muchChange the width of the box from 4 cm to 6 cm
Worked examples
StepDetail the robot still needs
1 Go to the tablewhich table, and how many steps to walk
2 Pick up the cupwhich cup, and hold it by the handle, not by the rim
3 Walk to the shelfwhich shelf, and how to avoid the chair on the way
4 Put the cup on the shelfwhich shelf height, and where along the shelf
Telling a helper robot to put a cup on a shelf. The short instruction hides many smaller ones. Each step in the list still needs details that a person would guess, so the writer keeps adding them until nothing is left to guess.
Python
1print(total)
2total = first + second
3first = 8
4second = 3
Output
NameError: name 'total' is not defined
The right order. In this program the first line asks for the value of total before any line has created it, so the computer stops with an error. With the lines in the right order (first = 8, second = 3, total = first + second, print(total)) the program prints 11. The computer cannot see that line 2 should have come first.
Order of stepsWorkingResult
add 5, then double(10 + 5) × 230
double, then add 510 × 2 + 525
Same steps, different order, different answer. Start with 10 and use two steps: add 5, and double. Adding first gives (10 + 5) × 2 = 30. Doubling first gives 10 × 2 + 5 = 25. A computer does what the list says in the order written, so the writer must choose the order that gives the answer wanted.
Class activity

The literal partner (no computer). Draw a 3 × 3 grid on paper and put six coins or buttons in a pile. Write six numbered instructions that place the coins to make a pattern that only you have seen, for example an L-shape. Do not tell your partner what the pattern is. Your partner plays the processor: they do exactly what each line says, one line at a time, and nothing more. When they finish, compare the grid with your pattern. Find the line that was not precise or detailed enough, rewrite it, and swap roles.

Practice
1
Write precise or vague for each instruction.
InstructionPrecise or vague?
(a) Move the piece.?
(b) Move the red piece two squares to the right.?
(c) Save the file.?
(d) Save the file called notes in the folder Homework.?
(e) Do the sum.?
2
This program should print the cost of 4 boxes at 6 each, but it stops with the error shown. Explain why it stops, then write the three lines in an order that works. What does it print?
Python
1print(amount)
2amount = boxes * 6
3boxes = 4
Output
NameError: name 'amount' is not defined
3
Start with 6. Complete the table. What do you notice?
Order of stepsWorkingResult
subtract 2, then multiply by 3(6 − 2) × 3?
multiply by 3, then subtract 26 × 3 − 2?
4
Write four numbered instructions for a friend who has never done it before, telling them how to wash and dry their hands. Make each one precise, and put them in the right order.