-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudent_teacher.py
More file actions
executable file
·33 lines (25 loc) · 866 Bytes
/
student_teacher.py
File metadata and controls
executable file
·33 lines (25 loc) · 866 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
#!/usr/bin/env python3
class Person(object):
def __init__(self, name):
self.name = name
def get_details(self):
return self.name
class Student(Person):
def __init__(self, name, branch, year):
Person.__init__(self, name)
self.branch = branch
self.year = year
def get_details(self):
return "{} student {} and {} year".format(self.name, self.branch, self.year)
class Teacher(Person):
def __init__(self, name, classes):
Person.__init__(self, name)
self.classes = classes
def get_details(self):
return "{} teacher teached {}".format(self.name, ','.join(self.classes))
person1 = Person('tankoni')
student1 = Student('tt', 'CSE', 2020)
teacher1 = Teacher('kk', ['java', 'python'])
print(person1.get_details())
print(student1.get_details())
print(teacher1.get_details())