1# Python code to demonstrate the working of
2# sum()
3numbers = [1,2,3,4,5,1,4,5]
4
5# start parameter is not provided
6Sum = sum(numbers)
7print(Sum) # result is 25
8# start = 10
9Sum = sum(numbers, 10)
10print(Sum) # result is 10 +25 = 35
1numbers = [2.5, 3, 4, -5]
2
3# start parameter is not provided
4numbers_sum = sum(numbers)
5print(numbers_sum)
6
7# start = 10
8numbers_sum = sum(numbers, 10)
9print(numbers_sum)
1from collections import Counter
2
3x = {'both1':1, 'both2':2, 'only_x': 100 }
4y = {'both1':10, 'both2': 20, 'only_y':200 }
5
6z = dict(Counter(x)+Counter(y))
7
8print(z)
9[out]:
10{'both2': 22, 'only_x': 100, 'both1': 11, 'only_y': 200}