Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1balance = received - sent | AA record showing that Ava sent 5 coins to Ben, so Ava's balance goes down by 5 and Ben's goes up by 5 | |
| 2Ava -> Ben: 5 coins | BAva: 10 - 4 = 6, Ben: 4 | |
| 3Read the records in time order from the first one, starting every balance at 0 and updating after each record | CWork out how much digital currency a person owns by adding up what they received and subtracting what they sent | |
| 4Worked example: Ava is paid 10 coins and then sends 4 coins to Ben, so Ava owns 6 and Ben owns 4 | DMoney sent was added instead of taken away. The balance should be 10 - 4 = 6. | |
| 5Ava received 10 and sent 4, so balance = 10 + 4 = 14 | Efor each record in time order: update balances | |
| 6Ben's balance = only the coins he received, ignoring the coins he sent | FIgnoring the records where Ben is the sender. You must count all records, both money in and money out. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
balance — The amount of digital currency a person owns, found by adding up all the money they received and taking away all the money they sent in the blockchain records, in time order.balance ← 0
FOR EACH record IN blockchain
OUTPUT record.amountIF record.to = "Ava" THEN
balance ← balance + record.amount
ENDIFIF record.from = "Ava" THEN
balance ← balance - record.amount
ENDIFava ← 10 - 4
ben ← 0 + 4 - 1
cara ← 0 + 1SORT blockchain BY timestamp
FOR EACH record IN blockchain
OUTPUT record.from, record.to