GoalRecall analogue and digital data, binary, robot rules, block and text languages, prototypes and the stages of a project plan.
New words
digitise · to change analogue data, such as sound, into numbers a computer can storesensor · a part that measures something, such as light or distancesyntax · the spelling and punctuation rules of a programming languageprototype · a model of a program that users test before the final version is built
Explanation
The real world is analogue, so a computer digitises sound and light into numbers, which it keeps in binary. In four bits the places are worth 8, 4, 2 and 1, and we add up the places that hold a 1. A robot uses sensors, and its program has rules such as if the front is clear, move forward, else stop. A program can be made of blocks or typed in a text language such as Python. Text languages are strict about syntax, so a missing bracket or a misspelt word is an error. Before building a program, we can test a prototype with users. A project plan has five stages: requirements, design, implementation, testing and evaluation, and we go round them again to make a better version.
Place value
8
4
2
1
Example bits
1
0
1
0
Worth
8
0
2
0
Worked examples
Number
8
4
2
1
13
1
1
0
1
7
0
1
1
1
The bits in the picture above, 1010, are worth 8 + 0 + 2 + 0 = 10. To write 13, take the biggest place that fits, then the next: 13 = 8 + 4 + 1, so 13 is 1101.
Robot on square
Front
1
clear
2
clear
3
wall
A cleaning robot follows one rule: if the square in front is clear, move forward, else stop. It starts on square 1. Squares 1 and 2 have a clear front and square 3 has a wall in front. The robot moves to square 2, then to square 3, and it stops there.
Python
1age = 112if age >= 12:
3print("Senior")
4else:
5print("Junior")
Output
Junior
This Python program has no errors. The value of age is 11. The test age >= 12 is false, so the else part runs and the program prints Junior.
Stage
For the cleaning robot
Requirements
clean the window and stop at the edge
Design
draw the flowchart of the rule
Implementation
write the program
Testing
try windows of different sizes
Evaluation
did it clean the whole window?
A project plan can be applied to a robot job. Each stage has its own question.
Class activity
Robot dance (no computer): one child is the robot and the others are programmers. Mark five squares on the floor and put a wall card after square 4. Write the rule on the board: if the square in front is clear, move forward, else stop. The robot follows the rule exactly. Then change the rule, for example turn left when the front is a wall, and play again. Finally, write the five project stages on cards and put them in order. Which stage would you do after the robot walks into the wall?
Practice
1
Write 14 in binary using four bits. Which places hold a 1?
Place value
8
4
2
1
Bits
?
?
?
?
14 = 8 + 4 + 2, so the bits are 1110. The places 8, 4 and 2 hold a 1.
2
What does the program print? Change one line so that it prints many.
It prints few, because 2 > 5 is false. Change the first line to count = 6 and it prints many.
3
A robot reads the squares ahead one at a time: clear, clear, dark, clear. Its rule is: if the reading is dark, turn left, else move forward. Write what the robot does.
Reading
1
2
3
4
Sensor
clear
clear
dark
clear
Forward, forward, turn left, forward.
4
Sort into analogue and digital: (a) a singer’s voice in the room, (b) the song saved on a tablet, (c) the light of the setting sun, (d) a number on a calculator. Which device turns the voice into numbers?
Analogue: (a) and (c). Digital: (b) and (d). A microphone with an analogue-to-digital converter turns the voice into numbers.