Multilevel inheritance in python

Multilevel inheritance:

  • Multilevel inheritance has derived from the class itself and derives the subclass further.
  • It means one base class derived from intermediate class, that intermediate class derived the derived class.

Syntax:
  1. class a:
             //Base class
    class b: class a
             //Intermediate class

    class c: class b
              //Derived class
    Object creation:
    Object_name=last_class_name() ;
    object_name.function(parameter list);
Example:
  1. #Multi level inheritance

    class bank:

        def pin_set(self):

            lst=[1111,1234,2222]

            print("\tWelcome to XXX bank")

            return lst

    class getvalue(bank):

        def get_data(self):

            pin=int(input("Enter pin number:"))

            return pin

    class pin_validation(getvalue):

        def verification(self,pin,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:

1 comment:

  1. Thank you for sharing an amazing & wonderful blog. This content is very useful, informative and valuable in order to enhance knowledge. Keep sharing this type of content with us & keep updating us with new blogs. Apart from this, if anyone who wants to join the Python Advanced training institute in Delhi, can contact 9311002620 or visit our website-
    https://www.htsindia.com/Courses/python/online-python-training-institute

    ReplyDelete

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