Daily Python Projects

Daily Python Projects

Class Interaction in Python: Author and Book Classes

Level: Beginner

Ardit Sulce's avatar
Ardit Sulce
Sep 03, 2025
∙ Paid

Your task for today is to build two related classes — one for an author and one for a book. This project introduces you to how objects can interact with each other, and how to model real-world relationships in Python using OOP.

📝 Project Task

The program should:

  • Define a class Author with attributes:

    • name (string)

    • birth_year (integer)

  • Define a class Book with attributes:

    • title (string)

    • year (integer)

    • author (an Author object)

  • Add the following methods:

    • Book.get_info() → returns a string like "Book Title by Author Name"

    • Author.write_book(title, year) → returns a new Book instance associated with that author

Bonus (optional):

  • Let the author store all books they’ve written

  • Add __str__() methods for nicer printing

  • Add a method Author.get_bibliography() that prints all titles by the author

This project teaches you how to:

  • Build multiple classes that reference each other

  • Create object relationships

  • Model simple real-world systems like authors and their books

📌 Expected Output

a = Author("George Orwell", 1903)
b = a.write_book("1984", 1949)

print(b.get_info())  # 1984 by George Orwell
print(b.author.name) # George Orwell

💻 Launch This Project in Colab

Open the interactive Google Colab notebook for today’s project — with full instructions, hints, and solutions.

Click the button below to start coding — no setup needed:

Keep reading with a 7-day free trial

Subscribe to Daily Python Projects to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Ardit Sulce · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture