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# Purpose: Calculate canteen order totals # Author: J. Tran Date: 2025-03-14 | AA comment kept up to date after a change, so the documentation still matches what the code does | |
| 2# Updated 2025-05-02: tax now 10% (was 8%) | B# Author: A. Patel print("Welcome") | |
| 3A comment above a function explains what it does, so another programmer can change it safely | C# Returns the total cost including GST def total_cost(price): | |
| 4Internal documentation sits inside the source code, next to the code it describes | DThe comments only repeat the code and give no purpose. Better comments would explain why, for example that 0.1 is the discount rate. | |
| 5# Returns the average mark def get_total(marks): return sum(marks) | EThe comment is out of date. It says average but the function returns the total, so it misleads the next programmer. Update the comment or the code so they match. | |
| 6x = 0.1 # sets x to 0.1 y = x * 5 # multiplies x by 5 | FA header comment stating the program's purpose, author and date so a maintainer knows what the file is for and who wrote it |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
internal documentation — Comments inside the code, like a header with purpose, author and date, and notes on each function, that help others (or you later) understand and safely change the program.top = 100 # highest mark possible in the test# Purpose: track student marks
# Author: J. Nguyen
# Date: 12/03/2025# Calculate the area of a rectangle
def area(w, h):
return w * h# Add 10% GST to the price
total = price * 1.1# Purpose: Store and total student marks
# Author: J. Nguyen
# Date: 12/03/2025