sum

sum(iterable, /, start=0)

Returns the total of all the items of an iterable (built-in, numpy).

iterableiterable (list, tuple, dict etc) whose item's sum is to be found
Normally, items of the iterable should be numbers.
start(optional) this value is added to the sum of items of the iterable
The default value of start is 0 (if omitted)

REMARKS
* This is a built-in function.
* Sums start and the items of an iterable from left to right and returns the total. The iterable's items are normally numbers, and the start value is not allowed to be a string.
* For some use cases, there are good alternatives to sum(). The preferred, fast way to concatenate a sequence of strings is by calling ''.join(sequence). To add floating point values with extended precision, see math.fsum(). To concatenate a series of iterables, consider using itertools.chain().
* You can use the math.sumprod function to
* You can use the math.fsum function to
* For the Official documentation refer to python.org

import numpy as np 

numbers = [2.5, 3, 4, -5]

# start parameter is not provided
numbersSum = sum(numbers)
print(numbersSum)

# start = 10
numbersSum = sum(numbers, 10)
print(numbersSum)

© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited Top