Multiple inheritances:
- Multiple inheritances have a number of base classes and one derived class.
- It means the numbers of base classes are derived from one derived class.
Syntax:
Example:
Output:
If condition:
Else condition:
Multiple inheritances:
Syntax:
class a
//Base class1
class b
//Base class2
class c:public a,public b
//Derived class
//Object creation
Object_name=Derived_class_name();
object_name.function_name(parameter_list);
Example:
#Multiple inheritance
class bank:
def pin_set(self):
lst=[1111,1234,2222]
print("\tWelcome to XXX bank")
return lst
class getvalue:
def get_data(self):
pin=int(input("Enter pin number:"))
return pin
class pin_validation(bank,getvalue):
def verification(self,pin,lst):
# for i in lst:
if pin in lst:
print("Enter your
choice:\n1.Cash widrawel\n2.Cash deposite\n3.Mini statement")
else:
print("Invalid pin")
b=pin_validation()
l=[]
l=b.pin_set()
p=b.get_data()
b.verification(p,l)
Output:
If condition:
Else condition:
No comments:
Post a Comment