Python Programming - Classes - Discussion
Discussion Forum : Classes - General Questions (Q.No. 34)
34.
Consider the following Python code:
class Book:
def __init__(self, title, author):
self.title = title
self.author = author
class EBook(Book):
def __init__(self, title, author, format_type):
super().__init__(title, author)
self.format_type = format_type
# Create an instance of the EBook class
my_ebook = EBook("Python Basics", "John Doe", "PDF")
# Access and print attributes
print(my_ebook.title)
print(my_ebook.author)
print(my_ebook.format_type)
What will be the output of the code?
Answer: Option
Explanation:
The code creates an instance of the `EBook` class and prints the values of its attributes (`title`, `author`, `format_type`).
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers