Advertisement
imariia777

Untitled

Jul 9th, 2023
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. #1
  2. n = int(input())
  3. a = [0]
  4. for i in range(n):
  5.     x = int(input())
  6.     a = [i] * x
  7. print(a)
  8. answer: [2, 2, 2]
  9.  
  10. #2
  11. n = int(input())
  12. a = []
  13. for i in range(n):
  14.     a = a + [i] * i
  15. print(a)
  16. answer: [1, 2, 2]
  17.  
  18. #3
  19. n = int(input())
  20. a = []
  21. for i in range(n):
  22.     x = int(input())
  23.     a = a + [x]
  24. k = sum(a)
  25. m = len(a)
  26. print(k/m)
  27. answer: 4.2
  28.  
  29. #4
  30. n = int(input())
  31. m = int(input())
  32. a = []
  33. for i in range(n):
  34.     x = int(input())
  35.     a += [x]
  36. print(a[m])
  37. answer: 32
  38.  
  39. #5
  40. n = int(input())
  41. a = []
  42. b = []
  43. for i in range(n):
  44.     x = int(input())
  45.     a += [x]
  46.  
  47. for i in range(len(a)):
  48.     if i % 2 == 0:
  49.         b.append(a[i])
  50. print(a)
  51. print(b)
  52. answer: [1, 2, 3]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement