Finding Doctor Speciality || Inner class || Python
In this we are going to see a basic example of inner class for finding doctor speciality in Python Programming Language.



class Doctors:
    def __init__(self):
        self.name = 'Doctor'
        self.dermatologists = self.Dermatologists()
        self.neurologists = self.Neurologists()

    def display(self):
        print('In Doctors class')
        print('Name:', self.name)

    class Dermatologists:
        def __init__(self):
            self.name = 'Dr. Abhishek'
            self.degree = 'MBBS'

        def dermaDisplay(self):
            print("Name:", self.name)
            print("Degree:", self.degree)

    class Neurologists:
        def __init__(self):
            self.name = 'Dr. Amit'
            self.degree = 'DNB'

        def neuroDisplay(self):
            print("Name:", self.name)
            print("Degree:", self.degree)

d = Doctors()
d.display()
d1 = d.dermatologists
d2 = d.neurologists
d1.dermaDisplay()
d2.neuroDisplay()

# Coded By Dhiraj Shelke


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post