Advertisement
sigmachto

Untitled

Jul 9th, 2023
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.48 KB | None | 0 0
  1. # 1)Ответ: [54,84,10,58,54,84,10,58]
  2. # 2)
  3. '''
  4. import copy
  5. a = []
  6. for i in range(5):
  7.    a.append(int(input()))
  8. b = a[:]
  9. c = a.copy()
  10. d = copy.copy(a)
  11. e = copy.deepcopy(a)
  12. f = list(a)
  13. print(5,sum(a))
  14. #Ответ: 5 35
  15.  
  16. #3) Ответ: 966
  17.  
  18. #4)
  19. import sys
  20. s = 0
  21. def list_in_dict(animal):
  22.    a = {}
  23.    for i in range(len(animal)):
  24.        a[animal[i]] = n=animal.count(animal[i])
  25.    return a
  26. animal = ["cat", "cat", "dog", "dog", "bird",
  27. "capybara", "capybara", "capybara"]
  28. print(list_in_dict(animal))
  29. b = (sys.getrefcount('cat'))
  30. c = (sys.getrefcount('dog'))
  31. d = (sys.getrefcount('bird'))
  32. f = (sys.getrefcount('capybara'))
  33. k = (sys.getrefcount('1'))
  34. l = (sys.getrefcount('2'))
  35. i = (sys.getrefcount('3'))
  36. print(b + c + d + f, k + l + i)
  37. #Ответ: 28 3000000024
  38.  
  39. #5)
  40. backpack = ["capybara", "capyraba", "capyba", "capyba", "capybara",
  41. 2999, 2999, "capybara", [7, 7, 7], [7, 7, 7], [7, 7, 7],
  42. [7, 7, 7]] + [[8, 8]] * 5
  43. counter = 0
  44. anti_counter = 0
  45.  
  46. for i in range(len(backpack)):
  47.    for j in range(i + 1,len(backpack)):
  48.        if backpack[i] is backpack[j]:
  49.            counter += 1
  50.        if  backpack[i] == backpack[j]:
  51.            anti_counter += 1
  52. print(counter,anti_counter)
  53. #Ответ: 15 21
  54. # 6)
  55. salat_cezar = ['lettuce', 'chicken', 'cheese', 'sauce', 'tomatoes', 'croutons']
  56. salat_cezar.append(salat_cezar)
  57. salat_cezar[6].append('salt')
  58. salat_cezar[6].append('pepper')
  59. print(salat_cezar[4], salat_cezar[-1])
  60. # Ответ: tomatoes pepper
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement