Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This Comments that explain and justify data and code structures worksheet is part of the VCE Software Development - U3O1 - Programming 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 | |
|---|---|---|
| 1# total holds the running sum of all marks | A# loop through every mark to find the highest for mark in marks: | |
| 2# list used because the number of students can change | BA comment describing a variable's purpose: what the variable is for | |
| 3A comment that explains why a loop is used and what it achieves | CThe comment only repeats what the code does and does not explain what count is for. Better: # count tracks how many students passed | |
| 4A comment that justifies using a record to group related data of different types | DThe comment names the structure but gives no reason for choosing it. Better: # array used because the size is fixed at 30 students | |
| 5# set count to 0 count = 0 | E# record used to keep one student's name, age and mark together student = {"name": "Ava", "age": 16, "mark": 88} | |
| 6# this is an array scores = [0] * 30 | FA comment justifying the choice of data structure by giving the reason it was chosen |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
# array used because size is fixed — A comment that explains what a variable, array, record or algorithm is for and why it was chosen, rather than just repeating what the code does.#
total of all marks, used to find the average
total = 0# loop runs once for each of the 30 students
for i in range(30):
marks.append(0)# dictionary used so marks are found by name
marks = {}# repeat until a valid mark is entered
while mark < 0 or mark > 100:
mark = int(input("Mark: "))# list used because the size is fixed at 30
names = [""] * 30