Answer:
class Book:
def __init__(self, title, author, publisher, pub_date, edition, pages):
self.title = title
self.author = author
self.publisher = publisher
self.pub_date = pub_date
self.edition = edition
self.pages = pages
def printinfo(self):
print("Title:", self.title)
print("Author:", self.author)
print("Publisher:", self.publisher)
print("Publication Date:", self.pub_date)
print("Edition:", self.edition)
print("Pages:", self.pages)
class Encyclopedia(Book):
def __init__(self, title, author, publisher, pub_date, edition, pages, volume):
Book.__init__(self, title, author, publisher, pub_date, edition, pages)
self.volume = volume
def printinfo(self):
print("Title:", self.title)
print("Author:", self.author)
print("Publisher:", self.publisher)
print("Publication Date:", self.pub_date)
print("Edition:", self.edition)
print("Pages:", self.pages)
print("Volume:", self.volume)
Step-by-step explanation:
In this example, the Encyclopedia class is derived from the Book class and contains an additional attribute, volume, which stores the volume of the encyclopedia. The printinfo() method in the Encyclopedia class overrides the printinfo() method in the Book class by printing the same information as well as the volume of the encyclopedia.