Home >>Python Built-in Functions >Python sum() Function
Python sum() function is used to return a number that is the sum of all the items present in an iterable.
Syntax:sum(iterable, start)
Parameter | Description |
---|---|
iterable | This is a required parameter. It defines the sequence to sum. |
start | This is an optional parameter. It defines a value that is added to the return value. |
a = (1, 2, 3, 4, 5, 6, 7, 8, 9)
x = sum(a)
print(x)
a = (1, 2, 3, 4, 5, 6, 7, 8, 9)
x = sum(a, 7)
print(x)