[go: up one dir, main page]

0% found this document useful (0 votes)
10 views1 page

Core Python Question

The document outlines the structure of an employee management system using a list of dictionaries to store employee records. It specifies the required keys for each employee record and provides three functions: one to retrieve an employee by ID, another to calculate the average salary by department, and a third to find the highest-paid employee. Example employee data is also included to illustrate the format and functionality.

Uploaded by

Priyansu Nayak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Core Python Question

The document outlines the structure of an employee management system using a list of dictionaries to store employee records. It specifies the required keys for each employee record and provides three functions: one to retrieve an employee by ID, another to calculate the average salary by department, and a third to find the highest-paid employee. Example employee data is also included to illustrate the format and functionality.

Uploaded by

Priyansu Nayak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

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.

You might also like