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 | |
|---|---|---|
| 1total = sum(scores) | Asum() needs a single list (or other iterable) as its argument, not separate numbers. It should be sum([10, 20, 30]). | |
| 2lowest = min(scores) | BSquare brackets were used instead of round brackets. A function call needs min(scores). | |
| 3Find the largest value in a list in one line instead of writing a loop | CFinds the smallest value in the list scores and stores it in lowest | |
| 4Calculate an average by combining sum() with len() | Dhighest = max(scores) | |
| 5total = sum(10, 20, 30) | Eaverage = sum(scores) / len(scores) | |
| 6smallest = min[scores] | FAdds up every number in the list scores and stores the total, with no loop needed |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
sum(), min(), max() — Built-in functions that return the total, smallest and largest value in a list, replacing a hand-written loop with one short, clear line of code.scores = [72, 85, 90, 64]
total = sum(scores)scores = [72, 85, 90, 64]
lowest = min(scores)scores = [72, 85, 90, 64]
highest = max(scores)prices = [4.5, 12, 7.25]
print("Total:", sum(prices))temps = [18, 24, 31, 22]
spread = max(temps) - min(temps)