Advertisement
Nenogzar

Untitled

Feb 17th, 2024
664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. def filter_numbers_above_average(numbers, average_sum):
  2.     above_average_list = []
  3.  
  4.     count = 0
  5.     for number in numbers:
  6.         if number > average_sum:
  7.             above_average_list.append(number)
  8.             count += 1
  9.  
  10.         if count == 5:
  11.             break
  12.  
  13.     return above_average_list
  14.  
  15. def main():
  16.     number_sequence = sorted(map(int, input().split()), reverse=True)
  17.     average_number = sum(number_sequence) / len(number_sequence)
  18.  
  19.     top_five_greatest_numbers = filter_numbers_above_average(number_sequence, average_number)
  20.  
  21.     if not top_five_greatest_numbers:
  22.         print("No")
  23.     else:
  24.         print(*top_five_greatest_numbers, sep=" ")
  25.  
  26. if __name__ == "__main__":
  27.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement