Advertisement
SimeonTs

SUPyF2 Lists-Advanced-Lab - 05. The Office

Oct 9th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.69 KB | None | 0 0
  1. """
  2. Lists Advanced - Lab
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1730#4
  4.  
  5. SUPyF2 Lists-Advanced-Lab - 05. The Office
  6.  
  7. Problem:
  8. You will receive two lines of input: a list of employee's happiness as string
  9. with numbers separated by a single space and a happiness improvement factor (single number).
  10. Your task is to find out if the employees are generally happy in their office.
  11. To do that you have to increase their happiness by multiplying the all the employee's happiness
  12. (the numbers from the list) by the factor, filter the employees which happiness is greater than or equal
  13. to the average in the new list and print the result
  14. There are two types of output:
  15. • If the half or more of the employees have
  16. happiness >= than the average: "Score: {happy_count}/{unhappy_count}. Employees are happy!"
  17. • Otherwise:
  18. "Score: {happy_count}/{unhappy_count}. Employees are not happy!"
  19.  
  20. Examples:
  21. Input:
  22. 1 2 3 4 2 1
  23. 3
  24. Output:
  25. Score 2/6. Employees are not happy!
  26. Comments:
  27. After the mapping:
  28. 3 6 9 12 6 3
  29. After the filtration:
  30. 9 12
  31. 2/6 people are happy, so the overall happiness is bad
  32.  
  33. Input:
  34. 2 3 2 1 3 3
  35. 4
  36. Output:
  37. Score: 3/6. Employees are happy!
  38. Comments:
  39. Half of the people are happy, so the overall happiness is good
  40. """
  41.  
  42. employees = [int(i) for i in input().split()]
  43. improvement_factor = int(input())
  44. employees = [employee * improvement_factor for employee in employees]
  45. filtered = [emp for emp in employees if emp >= (sum(employees) / len(employees))]
  46. if len(filtered) >= len(employees) / 2:
  47.     print(f"Score: {len(filtered)}/{len(employees)}. Employees are happy!")
  48. else:
  49.     print(f"Score: {len(filtered)}/{len(employees)}. Employees are not happy!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement