Problem 1 - Creating a book library
Let's say you have a lot of books and want to create an algorithm that stores information about the books. You want to record each book's title, author, publication date, and number of pages. Create an algorithm for this scenario.
First, let's think about the problem:
- The number of books I own changes constantly, so I'd want to create something that I can add information to, as needed.
- I also want to be able to remove books that I no longer own.
While we could use a library, the best solution for this particular problem would be a class. Let's start by creating a class called Books
:
ch8_BookLibrary.py
class Books: def __init__(self, title, author, pubDate, pages): self.title = title self.author = author ...