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 | |
|---|---|---|
| 1// Add 10% service charge to the bill Total ← Bill * 1.1 | AA good comment that explains the purpose of the calculation, not just the symbols used | |
| 2// Stop once the user enters -1 WHILE Score <> -1 | BFOR Count ← 1 TO 5 // Ask for one test mark INPUT Mark NEXT Count | |
| 3A comment should sit at the same indentation as the code it describes | C// Use MOD 2 to check if the number is even IF Number MOD 2 = 0 THEN | |
| 4A good comment explains why the code does something, not just what it does | DThe comment is not at the same indentation as the code it describes, so it is not clear which code it belongs to. | |
| 5// Set Total to 0 Total ← 0 | EA comment that explains a non-obvious step, in this case the value that ends the loop | |
| 6WHILE Lives > 0 // Ask for a guess INPUT Guess ENDWHILE | FThe comment repeats the code word for word and adds no new information. A pointless comment like this just adds clutter. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
// explain purpose — A good comment explains why a section of code exists or a tricky step, without repeating the code word for word. Put it at the same indentation as the code it describes.// Convert minutes into whole hours
Hours ← Minutes DIV 60IF Age < 0 THEN
// Age cannot be negative
OUTPUT "Invalid age"// Total cost including 10% tax
TotalCost ← Price * 1.1// Pass mark is 40 out of 100
CONSTANT PassMark ← 40// Average of three test marks
Average ← (Mark1 + Mark2 + Mark3) / 3
OUTPUT Average