Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #1
- def dictionary(a):
- a = [int(i) for i in a]
- n = {}
- for i in a:
- n[i] = i
- return n
- a = input().split(', ')
- print(dictionary(a))
- answer: {1: 1, 2: 2, 3: 3, 4: 4, 5: 5}
- #2
- a = int(input())
- n = {}
- for i in range (1, a+1):
- n[i] = i ** 2
- print(n)
- answer: {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
- #3
- a = {'data1': 375,'data2': 567,'data3': -37 ,'data4': 21}
- c = 1
- for i in a:
- c *= int(a[i])
- print(c)
- answer: -165209625
- #4
- a = input()
- c = []
- for i in a:
- if i == ',' or i == '.' or i == ':' or i == ';' or i == '!' or i == '?':
- c.append(i)
- print(len(c))
- answer: 12
- #5
- a = []
- x = input()
- for i in x:
- 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':
- a.append(i)
- else:
- continue
- print(*sorted(set(a)))
- answer: 1 2 4 5 6 7 8 9
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement