child class in perent class

 child class in perent class

#perent class

class vehicle :

    def __init__(self,mileage,cost):

        self.mileage=mileage

        self.cost=cost

    

    def show_details(self):

        print("i am a vehicle")

        print("mileage of vehicle",self.mileage)

        print("cost of vehicle is",self.cost)

v1 = vehicle(24,2525252)

#child class

class car(vehicle):

    def __init__(self,mileage,cost,tyres,hp):

        super().__init__(mileage,cost)

        self.tyres=tyres

        self.hp=hp

    def show_car_details(self):

        print("Numbers of tyres in car: ",self.tyres)

        print("value of hourse power",self.hp)

        print("i am a car")

c1=car(240,2525235,8,999)

c1.show_car_details()

Numbers of tyres in car: 8 value of hourse power 999 i am a car

c1.show_details()

i am a vehicle mileage of vehicle 240 cost of vehicle is 2525235



Comments

Post a Comment

Popular posts from this blog

What is chopper

What is Resistor

Top 5 best Ethical hacking book for beginners