sibinasto

05. List Adv - 05. The Office - Lab

Feb 11th, 2021
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. happiness = [int(el) for el in input().split()]
  2. factor = int(input())
  3. multiplied_happiness_by_factor = [num * factor for num in happiness]
  4. # multiplied_happiness_by_factor = list(map(lambda num: num * factor, happiness))
  5. avg_happiness = sum(multiplied_happiness_by_factor) / len(multiplied_happiness_by_factor)
  6.  
  7.  
  8. happy_employees = [h for h in multiplied_happiness_by_factor if h > avg_happiness]
  9.  
  10. # happy_employees = []
  11. # for h in multiplied_happiness_by_factor:
  12. #     if h >= avg_happiness:
  13. #         happy_employees.append(h)
  14.  
  15. # happy_employees = list(filter(lambda h: h > avg_happiness, multiplied_hapinnes_by_factor))
  16.  
  17. half_n = len(multiplied_happiness_by_factor) / 2
  18.  
  19. if len(happy_employees) >= half_n:
  20.     print(f"Score: {len(happy_employees)}/{len(multiplied_happiness_by_factor)}. Employees are happy!")
  21. else:
  22.     print(f"Score: {len(happy_employees)}/{len(multiplied_happiness_by_factor)}. Employees are not happy!")
Advertisement
Add Comment
Please, Sign In to add comment