-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpy-no13.py(class and emp))
37 lines (30 loc) · 1.09 KB
/
py-no13.py(class and emp))
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
33
34
35
36
37
class Emp:
total = 0
male = 0
female = 0
high_salary = []
assistants = []
def __init__(self, name, role, gender, doj, salary):
self.name = name
self.role = role
self.gender = gender
self.doj = doj
self.salary = salary
Emp.total += 1
if gender.lower() == "male":
Emp.male += 1
elif gender.lower() == "female":
Emp.female += 1
if salary > 10000:
Emp.high_salary.append(self)
if role.lower() == "assistant manager":
Emp.assistants.append(self)
emp1 = Emp("John", "Manager", "Male", "2020-01-01", 12000)
emp2 = Emp("Jane", "Assistant Manager", "Female", "2021-02-01", 9500)
emp3 = Emp("Sara", "Assistant Manager", "Female", "2019-03-01", 15000)
emp4 = Emp("Mike", "Engineer", "Male", "2022-06-15", 8000)
print(f"Total Employees: {Emp.total}")
print(f"Male Employees: {Emp.male}")
print(f"Female Employees: {Emp.female}")
print(f"Employees with Salary > 10,000: {[e.name for e in Emp.high_salary]}")
print(f"Assistant Managers: {[e.name for e in Emp.assistants]}")