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 | |
|---|---|---|
| 1names = ['Ava', 'Liam'] scores = [88, 65] | AWith parallel lists, removing an item from one list leaves the other lists out of step, so names and scores no longer match | |
| 2class Student: def __init__(self, name, score): | BA class bundles the data (name, score) for one real-world thing into a single unit | |
| 3Data and behaviour live together: an object holds its own data and has methods that work on that data | Cdef add_points(self, n): self.points += n | |
| 4Modelling a real-world thing: one object stands for one student, pet or game character | Dava = Student('Ava', 88) | |
| 5names.remove('Ava') # scores still has Ava's mark | EParallel lists: related data is split across separate lists, so every list must be kept in the same order by hand | |
| 6student = {'name': 'Ava', 'score': 88} student['scroe'] = 90 | FA dictionary has no fixed structure or built-in behaviour, so a typo in a key silently creates a new key instead of giving an error |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
object-oriented programming — A way of writing programs that groups related data and the code that uses it into one unit called an object, so programs modelling real things are easier to organise than separate lists and functions.names = ["Ava", "Liam"]
points = [120, 95]
print(names[0], points[0])students = [{"name": "Ava", "pts": 120}]
for s in students:
print(s)class Student:
def show(self):
print("Hi")class Dog:
def bark(self):
print("Woof")class Car:
pass
mine = Car()