-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path40.py
23 lines (21 loc) · 876 Bytes
/
40.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Define a Employee class with attributes role,department & salary.Also create showDetails() method.
# Create an Engineer class that inherits properties from employee & also have attributes: name & age
class Employee:
def __init__(self, role, dept, salary):
self.role = role
self.dept = dept
self.salary = salary
def showDetails(self):
print("name =", self.name)
print("age =", self.age)
print("role =", self.role)
print("dept =", self.dept)
print("salary =", self.salary)
class Engineer(Employee): # single Inheritance
def __init__(self, name, age):
self.name = name
self.age = age
super().__init__("Software Engineer", "IT", "Rs. 1,00,000")
# super() method used to access method of parent class
engg1 = Engineer("Arnav Singh",29) #instance
engg1.showDetails()