Multiple inheritances in python

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:

  1. 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:

  1. #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:

Share:

No comments:

Post a Comment

Popular Posts

Search This Blog

Powered by Blogger.

Service Support

Need our help to Learn or Post New Concepts Contact me

Recent Posts

Service Support

Need our help to Learn or Post New Concepts Contact me