python sum() code example
Example 1: python reduce()
from functools import reduce
items = [1,2,3,4,5]
sum_all = reduce(lambda x,y: x + y, items)
print (sum_all)
Example 2: sum() python
numbers = [2.5, 3, 4, -5]
numbers_sum = sum(numbers)
print(numbers_sum)
numbers_sum = sum(numbers, 10)
print(numbers_sum)
Example 3: python sum
numbers = [2.5, 3, 4, -5]
numbers_sum = sum(numbers)
print(numbers_sum)
numbers_sum = sum(numbers, 10)
print(numbers_sum)
Example 4: python sum
a = 3
b = 5
c = sum (a + b)
print(c)