Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import copy
- import sys
- # Задание №1
- # 108
- # Задание №2
- n = int(input())
- L = [int(input()) for i in range(n)]
- Lc_1 = L[:]
- Lc_2 = L.copy()
- Lc_3 = copy.copy(L)
- Lc_4 = copy.deepcopy(L)
- Lc_5 = list(L)
- print(5, sum(L))
- # Задание №3
- # 966
- # Задание №4
- animals = ["cat", "cat", "dog", "dog", "bird", "capybara", "capybara", "capybara"]
- animals_dict = {animal : 0 for animal in set(animals)}
- for animal in animals:
- animals_dict[animal] += 1
- sum_refs_animal = sum([sys.getrefcount(animal) for animal in animals_dict.keys()])
- sum_refs_nums = sys.getrefcount(1) + sys.getrefcount(2) + sys.getrefcount(3)
- print(sum_refs_animal, sum_refs_nums)
- # Задание №5
- backpack = ["capybara", "capyraba", "capyba", "capyba", "capybara", 2999, 2999, "capybara", [7, 7, 7], [7, 7, 7], [7, 7, 7], [7, 7, 7]] + [[8, 8]] * 5
- count_couple_equal = 0
- count_couple_same = 0
- length = len(backpack)
- for elem_1 in range(length-1):
- for elem_2 in range(elem_1+1, length):
- if backpack[elem_1] is backpack[elem_2]:
- count_couple_same += 1
- if backpack[elem_1] == backpack[elem_2]:
- count_couple_equal += 1
- print(count_couple_same, count_couple_equal)
- # Задание №6
- recursive_salat = ['lettuce', 'chicken', 'cheese', 'sauce', 'tomatoes', 'croutons']
- recursive_salat.append(recursive_salat)
- recursive_salat[6].append('salt')
- recursive_salat[6].append('pepper')
- recursive_salat_iteration_127 = recursive_salat[6]
- for i in range(126):
- recursive_salat_iteration_127 = recursive_salat_iteration_127[6]
- # На самом деле не обязательно рекурсивно погружаться в этот список 127 раз, поскольку он содержит ссылку на себя
- print(recursive_salat_iteration_127[4], recursive_salat[6][-1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement