You are working on an employee management system for a company.
The company
maintains employee records in a list of dictionaries, where each dictionary stores
the details of an employee.
Each employee record has the following keys:
1."id": A unique employee ID (integer)
2. "name": Employee name (string)
3. "department": Department name (string)
4. "salary": Monthly salary (integer)
Example:
employees = [
{"id": 101, "name": "Alice", "department": "HR", "salary": 50000},
{"id": 102, "name": "Bob", "department": "IT", "salary": 75000},
{"id": 103, "name": "Charlie", "department": "Finance", "salary": 60000},
{"id": 104, "name": "David", "department": "IT", "salary": 80000},
{"id": 105, "name": "Eve", "department": "HR", "salary": 55000}
]
Question 1:
Write a function get_employee_by_id(emp_list, emp_id) that returns the employee
dictionary based on the given employee ID. If the ID does not exist, return
"Employee not found".
Question 2:
Write a function get_avg_salary_by_department(emp_list, department) that calculates
and returns the average salary for employees in a given department. If the
department has no employees, return 0.
Question 3:
Write a function get_highest_paid_employee(emp_list) that returns the dictionary of
the highest-paid employee.