class and method inheritance in python code example

Example 1: python inheritance

class Person:  
    name = ""  

    def __init__(self, personName):  
        self.name = personName  
  
    def showName(self):  
        print(self.name)  
  
class Student(Person): 				# Student inherits from Person superclass
    studentClass = ""  

    def __init__(self, studentName, studentClass):  
        Person.__init__(self, studentName)		# superclass constructor
        self.studentClass = studentClass  		# Student class specific
  
    def getStudentClass(self):  
        return self.studentClass  
  
  
person1 = Person("Dave")
person1.showName()                  # Dave
student1 = Student("Mary", "Maths")
print(student1.getStudentClass())   # Maths
student1.showName()                 # Mary

Example 2: inheritance in python 3 example

<__main__.Robot object at 0x7fd0080b3ba8> <class '__main__.Robot'>
<__main__.PhysicianRobot object at 0x7fd0080b3b70> <class '__main__.PhysicianRobot'>
Hi, I am James