LearnPy Hub
← Inheritance & Special Methods problems
Hard

Composition: Car Has an Engine

Write Engine(hp) with start() returning Engine HP hp started, and Car(model, hp) that has an Engine and whose drive() returns the engine message followed by , MODEL is driving.

Input

Two lines: model, hp.

Output

One line.

Sample 1

Input
Corolla
140
Output
Engine 140 hp started, Corolla is driving

Sample 2

Input
Tesla
670
Output
Engine 670 hp started, Tesla is driving
solution.py
Output appears here
Composition: Car Has an Engine · Python practice problem · LearnPy Hub