Advertisement
imariia777

Untitled

Aug 3rd, 2023
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. #1
  2. def dictionary(a):
  3.     a = [int(i) for i in a]
  4.     n = {}
  5.     for i in a:
  6.         n[i] = i
  7.     return n
  8.  
  9. a = input().split(', ')
  10. print(dictionary(a))
  11. answer: {1: 1, 2: 2, 3: 3, 4: 4, 5: 5}
  12.  
  13. #2
  14. a = int(input())
  15. n = {}
  16. for i in range (1, a+1):
  17.     n[i] = i ** 2
  18. print(n)
  19. answer: {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
  20.  
  21. #3
  22. a = {'data1': 375,'data2': 567,'data3': -37 ,'data4': 21}
  23. c = 1
  24. for i in a:
  25.     c *= int(a[i])
  26. print(c)
  27. answer: -165209625
  28.  
  29. #4
  30. a = input()
  31. c = []
  32. for i in a:
  33.     if i == ',' or i == '.' or i == ':' or i == ';' or i == '!' or i == '?':
  34.         c.append(i)
  35. print(len(c))
  36. answer: 12
  37.  
  38. #5
  39. a = []
  40. x = input()
  41. for i in x:
  42.     if i == '1' or i == '2' or i == '3' or i == '4' or i == '5' or i == '6' or i == '7' or i == '8' or i == '9' or i == '0':
  43.         a.append(i)
  44.     else:
  45.         continue
  46. print(*sorted(set(a)))
  47. answer: 1 2 4 5 6 7 8 9
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement