69.4k views
5 votes
PYTHON

Create & run a Python program to sort the six employee's salaries in ascending order and in descending order. Take screenshots of your created program & the program's execution (Output).

As the manager of the six employees, you have decided to give each of the employees a 5% salary increase. Write pseudocode for the 5% employees’ salary raise. Write an algorithm that computes the average weekly salary of the six employees.

The following is a weekly salary for six employees at one of the companies: $500, $300, $700, $400, $600, and $550

User Alalonde
by
8.5k points

1 Answer

4 votes

Final answer:

The Python program sorts employee salaries in ascending and descending order, applies a 5% raise, and calculates the average weekly salary. The pseudocode and algorithm provided demonstrate these processes in a simplified manner.

Step-by-step explanation:

To sort the employees' salaries and apply a salary increase, you can use the following Python program:

# The original weekly salaries
salaries = [500, 300, 700, 400, 600, 550]

# Sort salaries in ascending order
ascending_salaries = sorted(salaries)
print('Ascending order:', ascending_salaries)

# Sort salaries in descending order
descending_salaries = sorted(salaries, reverse=True)
print('Descending order:', descending_salaries)

# Apply a 5% raise to each salary
increased_salaries = [s * 1.05 for s in salaries]
print('Salaries with a 5% raise:', increased_salaries)

# Calculate the average weekly salary
average_salary = sum(increased_salaries) / len(increased_salaries)
print('Average weekly salary:', average_salary)

When you run this program, you'll get the salaries sorted in both orders, the new salaries after a 5% raise, and the average weekly salary. For pseudocode for the 5% raise:

FOR each salary IN salaries
salary = salary * 1.05
OUTPUT salary
ENDFOR

The algorithm to compute the average weekly salary is:

SET total to 0
FOR each salary IN increased_salaries
total = total + salary
ENDFOR
SET average_salary to total / number of salaries
OUTPUT average_salary

And for calculating the average, you take the sum of the increased salaries and divide it by the number of employees.

User Dave Davis
by
8.8k points