The python sum() function is used to sum all items in an iterable. Actually, this function adds the items of an iterable and returns the sum.
Start parameter is an option to use and items of the given iterable from left to right. Where iterable objects (list, tuple, dict, etc) should be numbered.
Example sum function in Python
Simple example code sum of a given integer list.
a = [1, 2, 3, 4, 5] res = sum(a, 7) print(res) print(type(res))
To add floating-point numbers with exact precision, then you should use math.fsum(iterable) instead.
Without start parameter
a = [1, 2, 3, 4, 5] res = sum(a) print(res)
Do comment if you have any doubts or suggestions on this Python function topic.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.