Constructor Inheritance

Mon 10 August 2026
class Parent:
    def __init__(self, name):
        self.name = name

class Child(Parent):
    def __init__(self, name, age):
        super().__init__(name)
        self.age = age

c = Child("Alice", 25)
print(c.name, c.age)
Alice 25


Score: 10

Category: chapter2_inheritance

Read More

Method Overriding

Mon 10 August 2026
class Animal:
    def sound(self):
        print("Animal makes sound")

class Dog(Animal):
    def sound(self):
        print("Dog barks")

d = Dog()
d.sound()  # Dog barks
Dog barks


Score: 10

Category: chapter2_inheritance

Read More

Multilevel Inheritance

Mon 10 August 2026
class Grandparent:
    def feature(self):
        print("Grandparent feature")

class Parent(Grandparent):
    pass

class Child(Parent):
    pass

c = Child()
c.feature()
Grandparent feature


Score: 10

Category: chapter2_inheritance

Read More

Real-World Inheritance Example

Mon 10 August 2026
class Vehicle:
    def start(self):
        print("Vehicle started")

class Car(Vehicle):
    def drive(self):
        print("Car is driving")

class Bike(Vehicle):
    def ride(self):
        print("Bike is riding")

car = Car()
bike = Bike()

car.start()
car.drive()

bike.start()
bike.ride()
Vehicle started
Car is driving
Vehicle started
Bike is riding …

Category: chapter2_inheritance

Read More
Page 1 of 1