-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp44.py
More file actions
27 lines (22 loc) · 866 Bytes
/
p44.py
File metadata and controls
27 lines (22 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
#Define a Employee class with attributes role, department & salary. This class also has a showDetails() method.
#Create an Engineer class that inherits properties from Employees & has additional attributes : name & age.
class Employee:
def __init__(self, role, dept, salary):
self.role = role
self.dept = dept
self.salary = salary
def showDetails(self):
print("Role :", self.role)
print("Dept :", self.dept)
print("Salary :", self.salary)
class Engineer(Employee):
def __init__(self, name, age):
self.name = name
self.age = age
super().__init__("Engineer", "IT", "75,000")
def showDetails(self):
print("Name :", self.name)
print("Age :", self.age)
super().showDetails()
engg1 = Engineer("Elon Musk", 40)
engg1.showDetails()