In this article, we will learn to find the sum of the array using the python program.
So, we find the sum of the array in python using two methods
- using for loop
- using the sum() function
Method 1: Using for loop
- An array can be accessed by using indexes.
- So, first of all, we will find the length of the array.
- And then we iterate the for loop from 0 to the length array.
- And then we accessed the element of the array and add to him a variable named sum.
- Then, we print the sum variable.