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 | |
|---|---|---|
| 1total <- total + record.mark | AAdds each record's mark to a running total as the loop visits every record | |
| 2average <- total / count | BThe total is reset to 0 inside the loop, so every pass wipes out the earlier marks and only the last record is kept. | |
| 3Count only the records that match a condition by adding 1 to a counter inside an if statement | Cif record.mark >= 50 then count <- count + 1 | |
| 4Set the running total to 0 before the loop so each record can be added to it | DWorks out the average after the loop has finished, using the total and the number of records | |
| 5for each record in records total <- 0 total <- total + record.mark | Etotal <- 0 | |
| 6for each record in records total <- total + record.mark average <- total / count | FThe average is calculated inside the loop, before all records have been added and counted, so it is wrong until the last pass. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
aggregate — To aggregate is to combine many records into one summary value, such as a running total, a count of matching records, or an average worked out after the loop.total ← 0
for each sale in sales
total ← total + sale.amounttotal ← 0
for each sale in sales
total ← total + sale.amountcount ← 0
for each s in students
if s.mark >= 50 then count ← count + 1end for
average ← total / count
print averagetotal ← 0
for each sale in sales
total ← total + sale.amount