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 | |
|---|---|---|
| 1def __init__(name): | AError: balance is an attribute, not a method | |
| 2acc.balance() | BOk: Update an instance attribute in a method | |
| 3def __init__(self, name): | CValid: Constructor with self and a parameter | |
| 4self.balance += amount | DOutput: 7 | |
| 5round(3.14159, 2) | EOutput: 3.14 | |
| 6abs(-7) | FError: Missing self in __init__ |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Encapsulation — Bundling data and methods that operate on it together in a class.~~Stateclass BankAccount:
def deposit(self, amount):
self.balance += amountclass TodoList:
def add(self, task):
self.tasks.append(task)class BankAccount:
def withdraw(self, amount):
if amount <= self.balance:
self.balance -= amountacc = BankAccount('Alice', 100)
acc.deposit(50)class Score:
def __init__(self):
self.points = 0