rate, and Premium extends the cost method with super().
class Base:
rate = 2
def cost(self, n):
return n * self.rate
class Premium(Base):
rate = 3
def cost(self, n):
return super().cost(n) + 1
class Gold(Premium):
rate = 5
print(Base().cost(2), Premium().cost(2), Gold().cost(2))
What does the program print?Log in to join the discussion.
Loading…