Project: Library Management System
Combine classes, objects, and nested data structures to build a professional CLI tool.
Learning Objectives
- Model real-world entities using Classes
- Manage a collection of objects
- Implement complex logic with nested structures
- Use datetime for tracking events
Week 3 Milestone
You’ve made it through the most challenging part of Python: Object-Oriented Programming. Now, let’s combine your skills in classes, methods, and nested data to build a Library Management System.
Project Requirements
Your application should allow a user to:
- Register a new book (with title, author, and ISBN).
- Search for books by title.
- Borrow/Return books (updating their status).
- Log Transactions (record when a book was borrowed using
datetime).
Step 1: Modeling the Book
book.py
|
|
Step 2: The Library Class
Use a dictionary to store books, using their ISBN as a unique key.
library.py
|
|
Your Challenge
Complete the CLI interface in a main() function:
- Implement a loop that shows a menu (1. Add, 2. List, 3. Borrow, 4. Exit).
- Handle the logic for “Borrowing” a book by asking for its ISBN.
- Bonus: Add error handling to prevent the program from crashing if an ISBN isn’t found.
Interactive Practice
Visualize the relationship between the Library and its Books.
erDiagram
LIBRARY ||--o{ BOOK : contains
BOOK {
string title
string author
string isbn
boolean is_available
list history
}
Quiz
Complete this quiz with a minimum score of 80% to mark Day 21 as complete.
Loading quiz...
Discussion
Have questions or want to discuss this lesson? Join the conversation below!