how to create def function to sum in python code example
Example 1: sum() python
numbers = [2.5, 3, 4, -5]
# start parameter is not provided
numbers_sum = sum(numbers)
print(numbers_sum)
# output = 4.5
# start = 10
numbers_sum = sum(numbers, 10)
print(numbers_sum)
# output = 14.5
Example 2: python sum
x = [1,2,3,4,5]
s = sum(x)
print(s) # 15