Python Practice › OOP Programs › Program 11

Multilevel inheritance

EasyOOP Programs · 11 of 48

Write a Python program that demonstrates multilevel inheritance.

Advertisement
Output
4 petrol 300

Approach

  1. A grandchild inherits from a child, which inherits from a parent.

Solution

Python
class Vehicle:    def wheels(self):        return 4 class Car(Vehicle):    def fuel(self):        return "petrol" class SportsCar(Car):    def speed(self):        return 300 s = SportsCar()print(s.wheels(), s.fuel(), s.speed())
Output
4 petrol 300

Learn the concept

New to this topic? Read the lesson, then come back.

More oop programs

← All 48 OOP Programs

Leave a Comment