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 bark(): | AOk: Access instance attribute in a method | |
| 2dog.Bark() | BValid: Method with required self | |
| 3def bark(self): | COutput: HELLO | |
| 4self.name | DError: Method names are case-sensitive | |
| 5'hello'.upper() | EOutput: 2 | |
| 6[1,2,2].count(2) | FError: Missing self parameter |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Method — A function defined inside a class.~~selfclass Dog:
def bark(self):
return 'Woof!'class Dog:
def bark(self):
return self.name + ' says Woof!'dog = Dog('Rex')
print(dog.bark( ))class Counter:
def __init__(self):
self.count = 0
def increment(self):
self.count += 1class Circle:
def area(self):
return 3.14 * self.radius ** 2