koulin

Dynamic Tipization

Jul 5th, 2024
684
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. import copy
  2. # task 2
  3.  
  4. L = [int(input()) for _ in range(5)]
  5. C = L[:]
  6. C = copy.copy(L)
  7. C = copy.deepcopy(L)
  8. C = list(L)
  9.  
  10. #  task 4
  11. from sys import getrefcount
  12. def to_dict(array,name):
  13.     d = dict()
  14.     d[name] = array
  15.     return d
  16. N = int(input()) # кол-во животных
  17. animals = [input() for _ in range(N)]
  18. arr = to_dict(animals,'animals')
  19. summa = 0
  20. for x in arr['animals']:
  21.     summa += getrefcount(x)
  22. print(summa, getrefcount(1) + getrefcount(2) + getrefcount(3))
  23.  
  24. #task 5
  25. k = c = 0 # k - Одна ссылка, с - равные
  26. N = int(input())
  27. backpack = [input() for i in range(N)]
  28. for i in range(len(backpack)):
  29.     for j in range(i + 1, len(backpack)):
  30.         if backpack[i] is backpack[j]:
  31.             k += 1
  32.         if backpack[i] == backpack[j]:
  33.             c += 1
  34. print(k,c)
  35.        
  36. # task 6
  37. N = int(input()) # кол-во ингридиентов
  38. salad = [input() for _ in range(N)]
  39. salad += [salad]
  40. salad[6] += ['salt','pepper']
  41. print(salad[4], salad[-1])
  42.  
  43.  
  44.            
  45.        
  46.    
  47.  
  48.  
Advertisement
Add Comment
Please, Sign In to add comment