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 | |
|---|---|---|
| 1class Dog: def __init__(name): self.name = name | AOutput: 3 | |
| 2class Dog: def __init__(self, name): self.name = name Dog() | BValid: __init__ with parameter | |
| 3class Dog: def __init__(self, name): self.name = name | COutput: Rex | |
| 4d = Dog('Rex') print(d.name) | DError: Missing required arg 'name' | |
| 5class Dog: def __init__(self,n): self.name=n d=Dog('Rex') print(d.name) | EError: First param must be 'self' | |
| 6class Point: def __init__(self,x,y): self.x=x self.y=y p=Point(3,4) print(p.x) | FOk: Access attribute after creation |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
__init__ — Constructor method that runs automatically when an object is created.~~selfclass Dog:
def __init__(self, name):
self.name = nameclass Dog:
def __init__(self):
self.name = nameclass Dog:
def __init__(self, name):
self.name = namedog = Dog('Rex')
print(dog.name)class Person:
def __init__(self, name, age):
self.age = age