Python Program to Calculate Sum of An Array
Q. Write a Python program to calculate sum of an array of integers.
Using Python sum() Function:
The sum()
is the inbuilt Python function in python used for calculate sum of all the elements of an array of integers.
1 2 3 4 5 6 | # Creating an array with default integer elements arr = [1, 2, 45, 32, 7] result = sum(arr) print ('Sum of the array is ', result) |