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 | |
|---|---|---|
| 1account.deposit(50) | AThe code reaches into the class and does the working itself instead of calling a simple method like cart.get_total(). | |
| 2class Student: def __init__(self, name, year): | Bclass Book: def __init__(self, title, author): | |
| 3Abstraction lets you use a method without knowing how it works inside | CModels only the details needed (name and year) and leaves out everything else about a real student | |
| 4A good class design only includes attributes the program actually needs | Dprint(car.get_speed()) | |
| 5class Player: def __init__(self, name, shoe_size, eye_colour, lucky_number): | EToo many unneeded attributes. Abstraction means only modelling the details the program needs, such as name and score. | |
| 6total = 0 for item in cart.items: total = total + item.price | FUses a simple method to add money without needing to know how the balance is updated inside the class |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
abstraction — A class shows only the details needed to use it and hides the complicated working behind simple methods, so you can use a method without knowing how it works inside.class BankAccount:
def deposit(self, amount):
self.balance += amountaccount = BankAccount(100)
account.deposit(50)
print(account.balance)def deposit(self, amount):
self.balance += amountdef area(self):
return self.width * self.heightclass Thermostat:
def heat(self, temp):
self.temp = temp