Write a python function to sum all the numbers in a list
Example Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# Python 3 code to find sum # of elements in given array def _sum(arr,n): # return sum using sum # inbuilt sum() function return(sum(arr)) # driver function arr=[] # input values to list arr = [120, 30, 24, 5] # calculating length of array n = len(arr) ans = _sum(arr,n) # display sum print ('Sum of the array is ',ans) |
Output:
[…] Download Plan More @ http://www.code4example.com […]