Finding the sum of array elements
There are two ways to find the sum of all array elements, 1) traverse/access each element and add the elements in a variable sum, and finally, print the sum. And, 2) find the sum of array elements using sum() function.
Example:
Input:
arr = [10, 20, 30, 40, 50]
Output:
sum = 150
Python program for sum of the array elements
Output
need an explanation for this answer? contact us directly to get an explanation for this answer