By using Python:
a, Make a class called Book. The __init__() method for Book should store two attributes: a title and an author. Make a method called book_info() that prints these two pieces of information, and a method called book_available() that prints a message indicating that the book is available in the library.
b. Create an instance called book1 from your class. Print the two attributes individually, and then call both methods.
class Book: def __init__(self, title, author): self.title = title self.author = author def book_info(self): print("Title:", self.title) print("Author:", self.author) def book_available(self): print("the book is available in the library.") b = Book("Harry Potter", "J. K. Rowling") print(b.title) print(b.author) b.book_info() b.book_available()
Get Answers For Free
Most questions answered within 1 hours.