Menu
Coddy logo textTech

Book and User Classes

Part of the Object Oriented Programming section of Coddy's Python journey. Lesson 56 of 64.

challenge icon

Challenge

Easy

In this challenge, you'll implement the Book class for a library management system using a multi-file structure with comprehensive test coverage.

Edit book.py to implement the Book class following the TODO comments. The implementation should:

  1. Initialize with title, author, and ISBN parameters
  2. Track availability status and borrower information
  3. Implement proper string representation

Try it yourself

from book import Book

# 1. Create a Book object
book = Book("1984", "George Orwell", "345678")

# 2. Check attributes
print(book.title)       # Should print: 1984
print(book.author)      # Should print: George Orwell
print(book.isbn)        # Should print: 345678
print(book.available)   # Should print: True
print(book.borrower)    # Should print: None

# 3. Test __str__ when available
print(book)  # Should print: 1984 by George Orwell (ISBN: 345678) - Available

# 4. Test __str__ when not available
book.available = False
print(book)  # Should print: 1984 by George Orwell (ISBN: 345678) - Not Available

All lessons in Object Oriented Programming

Practice on your own: Online Python compiler