176k views
0 votes
The library can store up to 100 books. Each book has information of title, author, year, and a borrowed status (true or false). The library allows adding new books to it, checking out a book, and returning a book. We assume different books have different titles in the library.

1 Answer

4 votes

Answer:

class Books(object):

books_count = 0

books = {}

#classmethod

def book_count(cls):

cls.books_count +=1

#classmethod

def add(cls, title, author, year, status):

if cls.books_count < 100:

cls.book_count()

cls.books[title] = [author, year, status]

else:

print("Book register has reached it's limit.")

#classmethod

def check(cls, book_name):

return cls.books.get(book_name)

please replace the '#' with the 'at' sign.

Step-by-step explanation:

The python class defines several class methods namely; add, check and book_count. The add method adds books to the book dictionary in the class as a class attribute, the check method check for the presents of a book title in the book dictionary while the book_count method adds one to the books_count class variable which checks the dictionary size.