Calculate the sum of elements in an array using Python

Calculate the sum of elements in an array using Python

Sum of elements

To calculate the sum of elements in an array using Python language is bit easy as compared to he other programming language. In python it provide an inbuilt function sum() which sums up the numbers present in the list.
For Example
Enter the size of array : 5
Enter the elements in array :
4 2 10 5 9
The sum of elements : 30

Working required for finding sum of numbers in the list

Step1: Enter the user defined input of the list using input().
Step2: Initialize an empty list arr = [] .
Step3: Iterate through a each element using a For loop .
Step4: In the For loop append every element to the list.
Step5: Now we use predefined function sum() to find the sum of all the elements in a list.
Step6: Print the desired result.

Code in Python Language to calculate the sum of elements entered by the user

size=int(input("ENTER ARRAY SIZE"))
arr=[]
for i in range(size):
element=int(input())
arr.append(element)
print("SUM OF ARRAY : ",sum(arr))