Define a class 'son' derived from the class 'parent'.- Inherit the init function from the parent class and add a variable 'Percentage_for_son', which indicates the percentage of the inheritance he will get from the family's total asset worth. code example
Example: what is a child inheritance in python with example
class A:
def feature1(self):
print('Feature 1 in process...')
def feature2(self):
print('Feature 2 in process...')
class B:
def feature3(self):
print('Feature 3 in process...')
def feature4(self):
print ('Feature 4 in process...')
a1 = A()
a1.feature1()
a1.feature2()
a2 = B()
a2.feature3()
a2.feature4()
class A:
def feature1(self):
print('Feature 1 in process...')
def feature2(self):
print('Feature 2 in process...')
class B(A):
def feature3(self):
print('Feature 3 in process...')
def feature4(self):
print ('Feature 4 in process...')
a1 = A()
a1.feature1()
a1.feature2()
a2 = B()
a2.feature3()
a2.feature4()