Books
The digital revolution has knocked at the doors of the grand library. They are transitioning from conventional books to e-books. The cataloging system is managed by a Python program using a Book
class which stores attributes like title
, author
, and publication_year
.
Your task is to create a subclass named EBook
, which inherits from the Book
class. The EBook
class should have additional attributes like file_size
(in MB) and format
(like 'PDF', 'EPUB', 'MOBI', etc.).

The Book
class includes a __str__()
method that returns a string including the title, author, and publication_year in the format: "Title: {title}, Author: {author}, Published: {publication_year}". You should override this __str__()
method in the EBook
class to return a string that includes the title, author, publication_year, file_size, and format in the following format: "Title: {title}, Author: {author}, Published: {publication_year}, Size: {file_size} MB, Format: {format}".
Input | Output |
---|---|
| Title: To Kill a Mockingbird, Author: Harper Lee, Published: 1960 |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB