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 | |
|---|---|---|
| 1name <- upper(trim(raw[i].name)) | AWrites the good record to the new clean array, leaving the raw data untouched | |
| 2append clean, raw[i] | Bif raw[i].id = clean[j].id then isDuplicate <- true end if | |
| 3Skip a record with a missing value instead of copying it to the clean array | CTrims extra spaces and standardises the case of the text before it is stored | |
| 4Remove duplicates by comparing the key of the current record with keys already in the clean array | DThe check only rejects negative marks, so invalid values above the maximum (such as 150) still get through. It needs an upper limit, such as raw[i].mark >= 0 and raw[i].mark <= 100. | |
| 5for i from 1 to length(raw) raw[i].name <- upper(raw[i].name) append clean, raw[i] next i | Eif raw[i].mark = "" then continue end if | |
| 6for i from 1 to length(raw) if raw[i].mark >= 0 then append clean, raw[i] end if next i | FThe loop changes the raw array directly, so the original data is lost. It should store the cleaned value in a variable or in a copy of the record and write that to clean. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
cleaning algorithm — A loop that checks each record with if conditions, trims and standardises text, rejects or fixes bad values, and writes only the good records to a new clean array, leaving the raw data untouched.for i from 1 to length(raw)
name ← trim(raw[i].name)
append name to cleanfor i from 1 to length(raw)
name ← lower(trim(raw[i].name))
append name to cleanfor i from 1 to length(raw)
if raw[i].email ≠ "" then
append raw[i] to cleanage ← raw[i].age
if age >= 0 and age <= 120 then
append raw[i] to cleanif not contains(seenIDs, raw[i].id) then
append raw[i].id to seenIDs
append raw[i] to clean