GoalUse the four arithmetic operators in micro:bit blocks and predict what the display shows.
New words
operator · a symbol or block that does a calculation, such as + or ×result · the answer that a calculation givesmicro:bit · a small programmable board with a grid of 25 lights, two buttons and sensorsshow number · a block that scrolls a number across the lights of the board
Explanation
An arithmetic operator tells a computer how to combine two numbers. There are four. Add (+) finds a total. Subtract (−) finds a difference. Multiply (×) repeats an amount. Divide (÷) shares an amount equally. In typed code the symbols for multiply and divide are often * and /, because × and ÷ are not on most keyboards. In micro:bit blocks the operators fit into a slot like the pieces of a puzzle. A program usually works out a result, keeps it in a variable and then shows it with show number. When a number has two or more digits, the lights scroll it across the board one digit at a time. A block that sits inside another is worked out first, and this decides the order of a calculation.
Worked examples
Operator
On paper
Block
Example
Board shows
add
+
(a) + (b)
16 + 9
25
subtract
−
(a) − (b)
40 − 17
23
multiply
×
(a) × (b)
6 × 7
42
divide
÷
(a) ÷ (b)
45 ÷ 5
9
These four small programs each use one operator. After each press of the button the board scrolls the result. The answers are worked out in the blocks, not by the person.
The nesting of the blocks decides the order. In the first program the multiplication is inside the addition, so it is worked out first: 4 × 2 = 8, and then 3 + 8 = 11. In the second program the addition is inside the multiplication: 3 + 4 = 7, and then 7 × 2 = 14.
Problem
Calculation
Operator
5 books at 8 each
5 × 8 = 40
multiply
pay 50 for a bill of 38
50 − 38 = 12
subtract
share a bill of 36 between 4
36 ÷ 4 = 9
divide
Operators solve everyday problems. A shop multiplies the price by the number bought, subtracts the payment from the total to find the change and divides a bill to share it.
Class activity
Operator cards (no computer): make four cards with +, −, ×, ÷ and several number cards 1 to 12. Two players draw two number cards and one operator card. Each says the answer. A third player acts as the micro:bit and says ‘The board shows …’ only when the calculation is right. Use a check of 12 ÷ 4 = 3 and 4 × 3 = 12 to see how multiply and divide undo each other. Keep score. If you have a computer or tablet, build one of the programs in a micro:bit simulator.
Practice
1
What does the board show after A is pressed in each program?
Program A: 18 + 7 = 25. Program B: 50 − 19 = 31. Program C: 8 × 9 = 72.
2
Which program shows 23 and which shows 33?
Program 1 shows 23, because 6 × 3 = 18 is worked out first and 5 + 18 = 23. Program 2 shows 33, because 5 + 6 = 11 is worked out first and 11 × 3 = 33.
3
Write the blocks for a program that shows 9 times 6 when the button B is pressed. What does it show?
on button B pressed, show number ((9) × (6)). It shows 54.
4
Which operator would you use to (a) find how many in 4 packs of 12, (b) find the difference between 70 and 45, (c) share 30 sweets between 5 friends?