Classes and Object-Oriented Python Python lessons
Objects, attributes, methods, constructors, composition, and basic inheritance.
9 exercises8+ conceptsBeginner → interview context
Start this topicWHAT YOU WILL LEARN
Core concepts
Model a rectangle classModel a bank accountModel a student gradeBuild a shopping cartUse inheritance for employeesProtect temperature with a propertyCustomize book display and equalityUse a dataclass for inventory
REUSABLE THINKING
Problem-solving patterns
- class · methods
- encapsulation · state
- class · reuse
- aggregation · class
- inheritance · override
LESSON OUTCOME
What this topic builds
Learn the idea once, trace it through two verified cases, then explain why your approach works.
ORDERED LESSONS
All 9 lessons in this topic
Work from top to bottom to build each concept gradually.
- #077Model a rectangle classStarterPremium
Create a Rectangle for a room and call its measurement methods.
- #078Model a bank accountStarterPremium
Apply deposits and withdrawals to one account object.
- #079Model a student gradeBeginnerPremium
Create a student and determine the result from the average.
- #080Build a shopping cartBeginnerPremium
Add two product lines and calculate the cart total.
- #081Use inheritance for employeesBeginnerPremium
Calculate a manager's pay using a fixed bonus.
- #082Protect temperature with a propertyBeginnerPremium
Store a normal temperature through the validated property.
- #083Customize book display and equalityIntermediatePremium
Treat books with matching ISBNs as the same edition even if a title varies.
- #084Use a dataclass for inventoryIntermediatePremium
Create a concise inventory object and calculate its total stock value.
- #085Model compositionIntermediatePremium
Start a car composed with a petrol engine.