| |
- builtins.object
-
- Bookstore
class Bookstore(builtins.object) |
|
A bookstore class to hold books' names, their authors, and costs.
Attributes:
-----------
books : list
A list containing the books in the bookstore. Each book is represented as a tuple containing
its name, author, and cost.
Methods:
--------
add_book(bookname: str, author: str, cost: float):
Adds a new book to the bookstore.
remove_book(bookname: str):
Removes a book from the bookstore by its name.
print_current_books():
Prints the current list of books in the bookstore.
search_for_book(bookname: str) -> list:
Searches for a book by its name and returns a list of matching books. |
|
Methods defined here:
- __init__(self)
- Initializes an empty bookstore.
- add_book(self, bookname: str, author: str, cost: float)
- Adds a new book to the bookstore.
Parameters:
-----------
bookname : str
The name of the book.
author : str
The author of the book.
cost : float
The cost of the book.
Returns:
--------
None
- print_current_books(self)
- Prints the current list of books in the bookstore.
- remove_book(self, bookname: str)
- Removes a book from the bookstore by its name.
Parameters:
-----------
bookname : str
The name of the book to be removed.
Raises:
-------
ValueError
If the book doesn't exist in the bookstore.
- search_for_book(self, bookname: str) -> list
- Searches for a book by its name.
Parameters:
-----------
bookname : str
The name of the book to be searched.
Returns:
--------
list
A list of books that match the search.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |