Explain why changing first.room affects only the first workshop, while changing Workshop.organiser affects the value accessed through both workshops.
Identify which attributes in your explanation are instance attributes and which are class attributes. [2 marks]
Consider:
class Workshop:
organiser = "Computing"
def __init__(self, title, room):
self.title = title
self.room = room
def __str__(self):
return f"{self.title} in {self.room}"
first = Workshop("Python", "Online")
second = Workshop(room="Lab 3", title="Web")
first.room = "Lab 1"
Workshop.organiser = "Engineering"
print(first)
print(second)
print(first.organiser)
print(second.organiser)
State the exact four lines printed. [2 marks]
Explain:
[2 marks]
Explain the role of __str__ when Python executes:
print(first)
[1 mark]
advancement
track