<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Single Inheritance
In single inheritance, any client class inherits from only one parent class. Lets look at the below example which contains Pen as parent and BallPen & InkPen as clildren of it.
Step1:  BallPen & InkPen both are initializing the parent class using super().__init(size, name) function. Now lets create few objects of both,
Step2:  Lets create a parent class which inherits grand_parent class, note we have used super().__init_(middle_name) to set middle name using parents function middle_name.
Step3:  Now lets create the student which inherits parent class. Check its init also.
Step4:  Check the order of init's being called.
Step5:  Now lets create the same classes without init functions, and see what happens
Step6:  We got the error because, init of none of the parent's were called, and only students init was called.
<ASSISTANT_TASK:>
Python Code:
class Pen():
    def __init__(self, size, name):
        self.name = name
        self.size = size
    
    def set_name(self, name):
        self.name = name
class BallPen(Pen):
    def __init__(self, size, name, color):
        self.color = color
        super().__init__(size, name)
    
    def set_color(self, color):
        self.color = color
class InkPen(Pen):
    def __init__(self, size, name, cart_type):
        self.cart = cart_type
        super().__init__(size, name)
Explanation: Single Inheritance
In single inheritance, any client class inherits from only one parent class. Lets look at the below example which contains Pen as parent and BallPen & InkPen as clildren of it.
End of explanation
pb = BallPen(10, "Renolds", "Green")
print(pb.name)
pb.set_name("cello")
print(pb.name)
print(pb.__dict__)
class grand_parent:
    def __init__(self, middle_name):
        print("grand_parent init")
        self.__middle_name = middle_name
        
    def middle_name(self, middle_name):
        self.__middle_name = middle_name
        return self.__middle_name
Explanation: BallPen & InkPen both are initializing the parent class using super().__init(size, name) function. Now lets create few objects of both,
End of explanation
class parent(grand_parent):
    def __init__(self, middle_name, surname):
        print("parent init")
        self.__surname = surname
        super().__init__(middle_name)
    
    def middle_name(self):
        return self.middle_name
Explanation: Lets create a parent class which inherits grand_parent class, note we have used super().__init_(middle_name) to set middle name using parents function middle_name.
End of explanation
class student(parent):
    def __init__(self, name, middle_name, surname):
        print("student init")
        self.name = name
        super().__init__(middle_name, surname)
mohan = student("Venkat", "kumar", "Mohan")
Explanation: Now lets create the student which inherits parent class. Check its init also.
End of explanation
print(mohan.middle_name)
mohan.middle_name = "KUMAR"
print(mohan.middle_name)
Explanation: Check the order of init's being called.
End of explanation
class grand_parent:
    def __init__(self, middle_name):
        print("grand_parent init")
        self.__middle_name = middle_name
        
    def middle_name(self, middle_name):
        self.__middle_name = middle_name
        return self.__middle_name
class parent(grand_parent):
    def __init__(self, middle_name, surname):
        print("parent init")
        self.__surname = surname
    
    def middle_name(self):
        return self.__middle_name
    
    
class student(parent):
    def __init__(self, name, middle_name, surname):
        print("student init")
        self.name = name
mohan = student("Venkat", "kumar", "Mohan")
try:
    print(mohan.middle_name())
except Exception as e:
    print(e)
Explanation: Now lets create the same classes without init functions, and see what happens
End of explanation
# NOTE: python 2 has issues with Super , get it also documented here
Explanation: We got the error because, init of none of the parent's were called, and only students init was called.
End of explanation
<END_TASK>