Advertisement
boyan1324

23401

Feb 20th, 2024
978
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.37 KB | None | 0 0
  1. from math import ceil
  2. n = int(input())
  3. children = []
  4. adults = []
  5. for i in range(n):
  6.     person_age = int(input())
  7.     if person_age > 135:
  8.         print(f"System was hacked with {person_age} \n List - []")
  9.     elif 18 <= person_age <= 135:
  10.         adults.append(person_age)
  11.     elif person_age < 18:
  12.         children.append(person_age)
  13. count_children = len(children)
  14. count_adults = len(adults)
  15. average_adult_age = ceil(sum(adults) / count_adults)
  16. print(children)
  17. print(adults)
  18. print(f"Count of children: {count_children}")
  19. print(f"Count of adults: {count_adults}")
  20. print(f"Average age of adults: {average_adult_age}")
  21.  
  22. positive = []
  23. negative = []
  24. odd = []
  25. even = []
  26. n = int(input())
  27. for i in range(n):
  28.     num = int(input())
  29.     if num % 2 == 0:
  30.         even.append(num)
  31.     else:
  32.         odd.append(num)
  33.     if num > 0:
  34.         positive.append(num)
  35.     else:
  36.         negative.append(num)
  37. command = input("Enter command: ")
  38. if command == "positive":
  39.     print(f"Numbers {command}: {sorted(positive)}")
  40. elif command == "negative":
  41.     print(f"Numbers {command}: {sorted(negative)}")
  42. elif command == "odd":
  43.     print(f"Numbers {command}: {sorted(odd)}")
  44. elif command == "even":
  45.     print(f"Numbers {command}: {sorted(even)}")
  46.  
  47. data = input().split(", ")
  48. int_list = []
  49. for i in data:
  50.     current_element = int(i)
  51.     int_list.append(current_element)
  52. int_list.sort()
  53. str_list = []
  54. for i in int_list:
  55.     current_element = str(i)
  56.     str_list.append(current_element)
  57. average_points = sum(int_list) / len(int_list)
  58. print(f"Sorted list of points {' - '.join(str_list)}")
  59. print(f"Count of plays: {len(int_list)}")
  60. print(f"Worst play: {min(int_list)}")
  61. print(f"Best play: {max(int_list)}")
  62. print(f"Average points: {ceil(average_points)}")
  63.  
  64. grades = input().split(", ")
  65. grades_list = []
  66. for i in grades:
  67.     current_element = int(i)
  68.     grades_list.append(current_element)
  69. grades_list.sort()
  70. str_list = []
  71. for i in grades_list:
  72.     current_element = str(i)
  73.     str_list.append(current_element)
  74. average_points = sum(grades_list) / len(grades_list)
  75. print(f"Reverse sorted list of evaluations: {' '.join(str_list)}")
  76. print(f"Count of evaluations: {len(grades_list)}")
  77. print(f"Worst evaluation: {min(grades_list)}")
  78. print(f"Best evaluation: {max(grades_list)}")
  79. print(f"Count of sixes: {grades_list.count(6)}")
  80. print(f"Average evaluations: {average_points}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement