Advertisement
Brusnik

Untitled

Jul 8th, 2025
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.88 KB | None | 0 0
  1. import copy
  2. import sys
  3.  
  4. # Задание №1
  5.  
  6. # 108
  7.  
  8.  
  9. # Задание №2
  10.  
  11. n = int(input())
  12. L = [int(input()) for i in range(n)]
  13.  
  14. Lc_1 = L[:]
  15. Lc_2 = L.copy()
  16. Lc_3 = copy.copy(L)
  17. Lc_4 = copy.deepcopy(L)
  18. Lc_5 = list(L)
  19.  
  20. print(5, sum(L))
  21.  
  22.  
  23. # Задание №3
  24.  
  25. # 966
  26.  
  27.  
  28. # Задание №4
  29.  
  30. animals = ["cat", "cat", "dog", "dog", "bird", "capybara", "capybara", "capybara"]
  31. animals_dict = {animal : 0 for animal in set(animals)}
  32.  
  33. for animal in animals:
  34.     animals_dict[animal] += 1
  35.  
  36. sum_refs_animal = sum([sys.getrefcount(animal) for animal in animals_dict.keys()])
  37. sum_refs_nums = sys.getrefcount(1) + sys.getrefcount(2) + sys.getrefcount(3)
  38.  
  39. print(sum_refs_animal, sum_refs_nums)
  40.  
  41.  
  42. # Задание №5
  43.  
  44. backpack = ["capybara", "capyraba", "capyba", "capyba", "capybara", 2999, 2999, "capybara", [7, 7, 7], [7, 7, 7], [7, 7, 7], [7, 7, 7]] + [[8, 8]] * 5
  45. count_couple_equal = 0
  46. count_couple_same = 0
  47. length = len(backpack)
  48.  
  49. for elem_1 in range(length-1):
  50.     for elem_2 in range(elem_1+1, length):
  51.         if backpack[elem_1] is backpack[elem_2]:
  52.             count_couple_same += 1
  53.         if backpack[elem_1] == backpack[elem_2]:
  54.             count_couple_equal += 1
  55.  
  56. print(count_couple_same, count_couple_equal)
  57.  
  58.  
  59. # Задание №6
  60.  
  61. recursive_salat = ['lettuce', 'chicken', 'cheese', 'sauce', 'tomatoes', 'croutons']
  62.  
  63. recursive_salat.append(recursive_salat)
  64.  
  65. recursive_salat[6].append('salt')
  66. recursive_salat[6].append('pepper')
  67.  
  68. recursive_salat_iteration_127 = recursive_salat[6]
  69.  
  70. for i in range(126):
  71.     recursive_salat_iteration_127 = recursive_salat_iteration_127[6]
  72.  
  73. # На самом деле не обязательно рекурсивно погружаться в этот список 127 раз, поскольку он содержит ссылку на себя
  74.  
  75. print(recursive_salat_iteration_127[4], recursive_salat[6][-1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement