Editor

Create a Hybrid Class

Intermediate · Write the code · from Python Multiple Inheritance and MRO: How It Actually Works

From the lesson: Python Multiple Inheritance and MRO: How It Actually Works

Think about how you inherit traits from your parents. You might have your mom's eyes and your dad's sense of humor. You didn't pick one parent - you got traits from both.

Read the lesson

Create three classes:

  • Runner with a method run() that returns 'Running fast'
  • Climber with a method climb() that returns 'Climbing high'
  • Adventurer that inherits from both Runner and Climber and adds a method describe() that returns 'I can run and climb'
  • Create an Adventurer instance and print all three methods.

    # Create Runner, Climber, and Adventurer classes

    More Multiple Inheritance exercises

    All Python exercises · 50 practice problems · Object-Oriented Programming quiz