-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPolymorphism.py
More file actions
30 lines (20 loc) · 908 Bytes
/
Copy pathPolymorphism.py
File metadata and controls
30 lines (20 loc) · 908 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
# Function Overriding
class Employee:
def get_designation(self):
print("designation = Employee") # Method of Employee class
class Teacher(Employee):
def get_designation(self):
print("designation = Teacher") # Method of Teacher class
t1 = Teacher() # Object created of Teacher class
t1.get_designation() # call method
# Function Duck Typing => Walks like a duck & quacks like a duck
class Employee():
def get_designation(self):
print("designation = Employee") # Method of Employee class
class Accountant():
def get_designation(self):
print("designation = Accountant") # Method of Accountant Class
e1 = Employee() # Creating object of Employee class
e1.get_designation()
a1 = Accountant() # Creating Object of Accountant Class
a1.get_designation()