DS160123 using super method in class method

Date:-14/03/2023
Q_1) 1 parent class and 1 child class use constructor and super method.
class vehicle:
def init(self,colour,brand):
self.colour = colour
self.brand = brand
def display_vehicle(self):
print(self.colour,self.brand)
class car(vehicle):
def init(self,colour,brand,model):
super().init(colour,brand)
self.model = model
def display_car(self):
print(self.model)
Car=car(‘bmw’,‘blue’,‘hundai’)
Car.display_vehicle()
Car.display_car()
Q_2) 1 parent class and 1 child class name of the methods should be same and super method
class school:
def std(self):
print(‘ten’)
class div(school):
def std(self):
super().std()
print(‘five’)
Div=div()
Div.std()

2 Likes

@sms18680

Thank you for your valuable contribution.

2 Likes

Wow @sms18680
keep it up

1 Like