Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This Explaining data and code structures with comments worksheet is part of the VCE Applied Computing U1O2 Programming: Naming conventions and internal documentation journey. Print it as a booklet?
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 | |
|---|---|---|
| 1scores = [] # marks for each student | AA comment beside a class that explains what the class represents | |
| 2class Student: # one student's record | BThe comment only repeats the data type. It does not say what the list stores (marks for each student) or how it is used. | |
| 3A comment on an attribute states what it stores and its unit or range | Cself.mark = 0 # test mark out of 100 | |
| 4A comment on a loop explains what the loop does and why | Dfor s in scores: # add each mark to total | |
| 5scores = [] # list | EA comment beside a list that says what data it stores | |
| 6scores = [] // marks for each student | FPython comments start with #, not //. The // symbol is a syntax error here, so the comment is not valid. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
scores = [] # marks for each student — A comment beside a variable, list, record or class that says what it stores and how it is used, so other programmers can understand the data and code structures.scores = [] # marks for each studentclass Student:
# one student and their mark
def __init__(self, mark):# add every mark to the running total
for mark in scores:
total = total + mark# pass if the mark is 50 or more
if mark >= 50:
print("Pass")class Student:
# stores one student's mark out of 100
mark = 0