Python sum() FunctionAs the name says, python sum() function is used to get the sum of numbers of an iterable, i.e. list. Signaturesum(iterable, start) Parametersiterable - iterable can be list, tuples, and dictionaries, but an iterable object must contain numbers. start - The start is added to the sum of numbers in the iterable. If start is not given in the syntax, it is assumed to be 0. Let's see some examples of sum() function are given below: Python sum() Function Example 1This example shows sum of the list of numbers: Output: 5 15 Python sum() Function Example 2This example shows sum of floating point numbers: Output: 7.0 Python sum() Function Example 3This example shows sum of complex numbers: Output: (4+6j) (6+8j) (4.5+0j) Next TopicPython Built in Functions |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India