pyhton super

Solutions on MaxInterview for pyhton super by the best coders in the world

showing results for - "pyhton super"
Simón
28 Apr 2017
1class Person:  
2    name = ""  
3
4    def __init__(self, personName):  
5        self.name = personName  
6  
7    def showName(self):  
8        print(self.name)  
9  
10class Student(Person): 
11    studentClass = ""  
12
13    def __init__(self, studentName, studentClass):  
14        Super().__init__(self, studentName)
15        self.studentClass = studentClass  
16  
17    def getStudentClass(self):  
18        return self.studentClass  
19  
20  
21person1 = Person("Dave")
22person1.showName()                  # Dave
23student1 = Student("Mary", "Maths")
24print(student1.getStudentClass())   # Math
25student1.showName()                 # Mary