-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance2.py
More file actions
32 lines (24 loc) · 738 Bytes
/
Copy pathinheritance2.py
File metadata and controls
32 lines (24 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class person:
def __init__(self,fname,lname):
self.firstname=fname
self.lastname=lname
def printname(self):
print(self.firstname,self.lastname)
x=person("terence","mpofu")
x.printname()
class student(person):
pass
class student(person):
def __init__(self,fname,lname):
person.__init__(self,fname,lname)
class child(person):
def __init__(self,fname,lname):
super().__init__(fname,lname)
class Student(person):
def __init__(self,fname,lname,year):
super().__init__(fname,lname)
self.gradyear=year
def welcome(self):
print('welcome',self.firstname,self.lastname,"to the class of",self.gradyear)
a=Student('terence','mpofu',2010)
a.welcome()