- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Program to find average salary excluding the minimum and maximum salary in Python
Suppoe we have an array with distinct elements called salary where salary[i] is the salary of ith employee. We have to find the average salary of employees excluding the minimum and maximum salary.
So, if the input is like salary = [8000,6000,2000,8500,2500,4000], then the output will be 5125.0, as the minimum and maximum salary values are 2000 and 8500, so excluding them the average salary values are [8000,6000,2500,4000] so the average is (8000 + 6000 + 2500 + 4000)/4 = 5125.
To solve this, we will follow these steps −
delete minimum of salary from salary
delete maximum of salary from salary
return sum of the salary values / number of elements in salary after removal
Let us see the following implementation to get better understanding −
def solve(salary): salary.remove(min(salary)) salary.remove(max(salary)) return sum(salary)/len(salary) salary = [8000,6000,2000,8500,2500,4000] print(solve(salary))
- MySQL query to select maximum and minimum salary row?
- Write a program in Python to find the minimum age of an employee id and salary in a given DataFrame
- Select highest salary in MySQL?
- C Program to calculate the salesmen salary with macro functions.
- Find max and second max salary for a MySQL Employee table?
- Program to find maximum average pass ratio in Python
- MySQL edit and update records including employee salary
- Get the difference between dates and calculate salary with MySQL?
- What is the salary of ethical hacker in India?
- Find max and second max salary for a MySQL Employee table using subquery?
- 8085 program to find maximum and minimum of 10 numbers
- Golang Program to find the minimum and maximum number, using binary operations.
- Python program to find the maximum and minimum value node from a doubly linked list
- Python program to find the maximum and minimum value node from a circular linked list
- Kelley School of Business – Importance, Salary & Overview