Ask Question
30 September, 22:02

This represents a group of Book values as a list (named books). We can then dig through this list for useful information and calculations by calling the methods we're going to implement. class Library: Define the Library class. • def __init__ (self) : Library constructor. Create the only instance variable, a list named books, and initialize it to an empty list. This means that we can only create an empty Library and then add items to it later on.

+5
Answers (1)
  1. 30 September, 22:09
    0
    class Library: def __init__ (self) : self. books = [] lib1 = Library () lib1. books. append ("Biology") lib1. books. append ("Python Programming Cookbook")

    Explanation:

    The solution code is written in Python 3.

    Firstly, we can create a Library class with one constructor (Line 2). This constructor won't take any input parameter value. There is only one instance variable, books, in the class (Line 3). This instance variable is an empty list.

    To test our class, we can create an object lib1 (Line 5). Next use that object to add the book item to the books list in the object (Line 6-8).
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “This represents a group of Book values as a list (named books). We can then dig through this list for useful information and calculations ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers