✦ OPTIONAL MODULE FINAL CHALLENGE

Mini Library Manager

Mini Library Manager

Build one small project that connects the six OOP Basics lessons.

01 Your project02 Python Playground03 Success criteria

Mini Library Manager

Create a Book class with a constructor, class and instance attributes, borrow and return methods, and a validated year property. Create at least three independent books and demonstrate that borrowing one does not change the others.

↳

Run your code, then check the project to see how each Book behavior works.

Success criteria

  • Book has title, author, year, and availability state.
  • borrow(), return_book(), and display_info() work on one instance.
  • library_name is a class attribute and _year is validated through year.
  • Invalid years raise ValueError without replacing a valid year.

Python Playground

Loading Python runtime…

Run your code, then check the project to see how each Book behavior works.

library_manager.pyPython
OutputWaiting for Python
The browser runtime is loading. You can still edit the example code.

Pyodide runs Python in a browser Web Worker. It is stopped and restarted if code keeps running. Browser execution is not a complete security boundary; do not enter secrets or rely on it for untrusted code isolation.

Check your project

Run a private set of browser-based checks against your current code.

Check your current code when you are ready.

  • Book class and independent instancesCreates Book objects with their own title, author, year, and availability.Create two Book objects and store these values, including self.is_available, on each instance.
    Waiting
  • Borrowing and returningborrow() and return_book() change only the selected book’s availability.Set self.is_available to False in borrow() and True in return_book().
    Waiting
  • Shared library namelibrary_name is a class attribute shared by Book instances.Define library_name directly inside Book, not inside __init__.
    Waiting
  • Year propertyA getter and setter read and update year through _year.Use @property and @year.setter, then store valid values in self._year.
    Waiting
  • Safe year validationInvalid years raise ValueError and keep the previous valid year.Validate before assigning _year so invalid values cannot replace a valid year.
    Waiting
Sloby, the Python AI Tutor mascot

Sloby AI Mentor

Sign in for AI project help

Create a free account or sign in to ask Sloby for a hint or code review.