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# Skip students with no marks | A# Pass mark is 50 because the school policy says so | |
| 2"""Return the average of a list of marks.""" | BA comment that explains why the next lines of code are there | |
| 3Internal documentation explains why code was written, which helps a future programmer maintain it | CThe comment only repeats the code. It does not explain what x is or why it has this value, so it does not help a future programmer. | |
| 4Internal documentation supports maintenance by stating who made changes and what the file is for | DA docstring that describes what a function does for future programmers | |
| 5x = 0.1 # sets x to 0.1 | E# Author: J. Lee Purpose: Calculate house points | |
| 6total = total * 1.1 # Add GST # (code later changed to 1.15, comment not updated) | FThe comment is out of date and no longer matches the code, which misleads the programmer who maintains 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 — Explanation written inside the code to say what it does and why, so other programmers can understand, fix and update it later.price = 50
# Add 10% GST so the total is correct
total = price * 1.1def add_gst(price):
"""Return the price including GST."""
return price * 1.1# Why: GST is 10% in Australia
rate = 0.1
total = price + price * rate# Helps future programmers fix this code
def double(n):
return n * 2# Show the final mark to the student
print(mark)
# Maintenance: edit here to change format