Menu
Coddy logo textTech

Project Overview

Part of the Object Oriented Programming section of Coddy's Python journey — lesson 55 of 64.

challenge icon

Challenge

Medium

In this challenge, you'll implement the foundation for a Library Management System.

Edit library.py to implement the required classes following the TODO comments. The driver file contains extensive test scenarios that validate your implementation.

  • Follow the TODO comments in library.py for step-by-step guidance
  • Implement the Library class with proper initialization and string representation

Cheat sheet

The challenge focuses on implementing a Library Management System with proper class structure and string representation methods. No specific lesson content was provided to create a comprehensive cheatsheet.

Try it yourself

# TODO: Import the Library class from library.py
# Use format: from library import Library

# Comprehensive test case handler
test_case = input()

if test_case == "basic_library_creation":
    # TODO: Create a library with name "Test Library"
    # TODO: Print the library object (this will call the __str__ method)
    pass
    
elif test_case == "library_attributes":
    # TODO: Create a library with name "Test Library"
    # TODO: Print the library's name attribute in the format: Name: Test Library
    # TODO: Print the length of the books list in the format: Books: 0
    # TODO: Print the length of the users list in the format: Users: 0
    # Hint: Use f-strings, e.g. print(f"Name: {library.name}")
    pass

elif test_case == "multiple_libraries":
    # TODO: Create two different libraries with names "Library 1" and "Library 2"
    # TODO: Print both library objects
    pass

elif test_case == "empty_name":
    # TODO: Create a library with an empty string as the name
    # TODO: Print the library object
    pass

elif test_case == "special_characters":
    # TODO: Create a library with the name "!@#$%^&*()"
    # TODO: Print the library object
    pass

elif test_case == "very_long_name":
    # TODO: Create a library with a name of exactly 100 'A' characters (use "A" * 100)
    # TODO: Print the library object
    pass

elif test_case == "add_books_users":
    # TODO: Create a library with name "Test Library"
    # TODO: Add these items to the books list: ["Book1", "Book2", "Book3"]
    # TODO: Add these items to the users list: ["User1", "User2"]
    # TODO: Print the library object (should show updated counts)
    pass

elif test_case == "empty_lists":
    # TODO: Create a library with name "Test Library"
    # TODO: Print the length of the books list in the format: Books length: 0
    # TODO: Print the length of the users list in the format: Users length: 0
    # Hint: Use f-strings, e.g. print(f"Books length: {len(library.books)}")
    pass

elif test_case == "type_validation":
    # TODO: Create a library with the integer 123 as the name
    # TODO: Print the library object (should convert to string)
    pass

All lessons in Object Oriented Programming