Project Overview
Part of the Object Oriented Programming section of Coddy's Python journey — lesson 55 of 64.
Challenge
MediumIn 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.pyfor step-by-step guidance - Implement the
Libraryclass 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)
passAll lessons in Object Oriented Programming
1Fundamentals of OOP
External FilesIntroduction to OOPClasses vs ObjectsThe self ParameterMethodsAttributesConstructor Method (__init__)Recap - Simple Calculator4Inheritance
Basic InheritanceThe super() FunctionMethod OverridingMultiple InheritanceMethod Resolution OrderRecap - Employee Hierarchy7Special Methods
Magic Methods IntroductionOperator OverloadingContainer Magic MethodsRecap - Custom List10Design Patterns Part 1
Intro to design patternSingleton PatternFactory PatternObserver PatternStrategy Pattern2Decorators
Introduction to DecoratorsProperty DecoratorStatic Method DecoratorClass Method Decorator5Polymorphism
Method Overriding RevisitedDuck TypingAbstract Classes and MethodsInterface DesignRecap - Shape Calculator8Advanced OOP Concepts
Composition vs InheritanceMixinsStatic and Class MethodsClass DecoratorsContext Managers3Class Properties
Instance vs Class VariablesProperty DecoratorsPrivate AttributesRecap - Bank Account Manager6Encapsulation
Public, Protected, Private MemAccess ModifiersInformation HidingProperty Decorators AdvancedRecap - Student Records System12Project: Library Management
Project OverviewBook and User Classes