pyPython Practice LabFrom first print to final round
TOPIC 10 OF 18

Classes and Object-Oriented Python Python lessons

Objects, attributes, methods, constructors, composition, and basic inheritance.

9 exercises8+ conceptsBeginner → interview context
Start this topic
WHAT 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.

  1. #077
    Model a rectangle class

    Create a Rectangle for a room and call its measurement methods.

    StarterPremium
  2. #078
    Model a bank account

    Apply deposits and withdrawals to one account object.

    StarterPremium
  3. #079
    Model a student grade

    Create a student and determine the result from the average.

    BeginnerPremium
  4. #080
    Build a shopping cart

    Add two product lines and calculate the cart total.

    BeginnerPremium
  5. #081
    Use inheritance for employees

    Calculate a manager's pay using a fixed bonus.

    BeginnerPremium
  6. #082
    Protect temperature with a property

    Store a normal temperature through the validated property.

    BeginnerPremium
  7. #083
    Customize book display and equality

    Treat books with matching ISBNs as the same edition even if a title varies.

    IntermediatePremium
  8. #084
    Use a dataclass for inventory

    Create a concise inventory object and calculate its total stock value.

    IntermediatePremium
  9. #085
    Model composition

    Start a car composed with a petrol engine.

    IntermediatePremium