A book object gets its own shelf, which hides the class variable.
class Book:
shelf = "A"
def __init__(self, title):
self.title = title
def tag(self):
return self.shelf + self.title[0]
b = Book("Odyssey")
b.shelf = "B"
Which of these expressions are True? Choose every correct option.
One or more options are correct. Tick all the correct ones: a wrong option costs marks, and a part-right answer earns part of the marks.
Log in to join the discussion.
Loading…