Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

sum function python

sum(a)
a is the list , it adds up all the numbers in the 
list a and takes start to be 0, so returning 
only the sum of the numbers in the list.
sum(a, start)
this returns the sum of the list + start 
// Python code to demonstrate the working of 
// sum()
   
numbers = [1,2,3,4,5,1,4,5]
  
// start parameter is not provided
Sum = sum(numbers)
print(Sum)
  
// start = 10
Sum = sum(numbers, 10)
print(Sum)
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #sum #function #python
ADD COMMENT
Topic
Name
8+7 =