Create a Book Class
Beginner · Write the code · from Python Classes and Objects: OOP from the Ground Up
From the lesson: Python Classes and Objects: OOP from the Ground Up
Imagine you own a bakery and you have a cookie cutter shaped like a star. Every time you press it into dough, you get a new star-shaped cookie. The cutter itself isn't a cookie - it's a blueprint for making cookies.
Read the lessonCreate a Book class with an __init__ method that takes title, author, and pages as parameters and stores them as instance attributes. Then create a book with title '1984', author 'George Orwell', and pages 328. Print each attribute on its own line.
# Create your Book class here
More Classes and Objects exercises
- Add a Method to RectangleBeginner
- Predict the Counter OutputBeginner
- Fix the Student ClassIntermediate
- Add __str__ to a ProductIntermediate
- Build a Player Class with Score TrackingIntermediate
- Refactor Functions into a ClassAdvanced
All Python exercises · 50 practice problems · Object-Oriented Programming quiz