Search⌘ K

Challenge 1: Cars and Engines!

Explore how to implement object relationships in Python by creating a Sedan class that inherits from Car and composes a SedanEngine object. Learn to manage composition, inheritance, and method calls while practicing coding with a real-world example of cars and engines.

Problem statement

You have to implement a Sedan class, which inherits from the Car class and contains a SedanEngine object.

Note: In such a composition relation, the Sedan class will be responsible for SedanEngine lifetime.

Consider this diagram for reference:

Task 1

  • The Car initializer should take arguments ...