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

Term 2 review

Week 21 · Review: Term 2 · 3 lessons
3

Tables, inputs and outputs

Computing 4: Units 5–8, pp. 62–122
GoalSearch a data table with two rules and write a micro:bit algorithm with a repeat step.
New words
record · one row of a table, holding all the facts about one thingfield · one column of a table, such as colour or weightinput device · a part that sends information to the computer, such as a button or a light sensoroutput device · a part that gives out information, such as an LED display or a speaker
Explanation

A table keeps data in rows and columns. Each row is a record, and each column is a field. To search a table, read the rule and check the records one by one. With two rules joined by AND, a record must pass both. Each field has a data type: Text, Number, Date/Time or Yes/No. A micro:bit shows how inputs and outputs work. A button, a sensor or shaking is an input. The LED display and a speaker are outputs. To plan a micro:bit program, we split it into parts and write an algorithm with a repeat step. A step that repeats steps 2 to 4 two more times plays the round 3 times in all.

ToolColourWeight (kg)Needs oil
Spadegreen4no
Rakegreen2no
Hoered1yes
Shearsred2yes
Trowelblue1no
Forkgreen3no
Worked examples
ToolGreen?Over 2 kg?Both?
Spadeyesyesyes
Rakeyesnono
Hoenonono
Shearsnonono
Trowelnonono
Forkyesyesyes
Search the tool table with two rules: the colour is green and the weight is more than 2 kg. Check each record against both rules.
StepInstruction
1Start program when button A is pressed
2Show heart icon
3Wait 1 second
4Clear screen
5Repeat steps 2 to 4 two more times
6Stop program
A micro:bit gadget. Button A starts it and the heart is shown 3 times in all. Each round has the same three steps.
PartInput or output?
button Ainput
light sensorinput
LED displayoutput
speakeroutput
Sorting parts of a micro:bit into inputs and outputs.
Class activity

Detective table (with family): make a table of five things in your home, for example pans, books or shoes. Choose three fields, for example name, colour and weight, and fill in the records. Write one search with a single rule and one with two rules joined by AND. Ask someone to find the answers. Then think of a gadget with a button and a light, and write its algorithm with a repeat step.

Practice
1
In the tool table, how many fields and how many records are there?
2
Search the tool table for needs oil is yes AND weight is 2 kg. Which tool is found?
3
Say the data type of each data item from the tool table.
Data itemFieldData type
3Weight (kg)?
SpadeTool?
yesNeeds oil?
4
A gadget shows the diamond icon for 2 seconds each time. Button B starts it and it shows the diamond 4 times in all. Write step 5.
StepInstruction
1Start program when button B is pressed
2Show diamond icon
3Wait 2 seconds
4Clear screen
5?
6Stop program