0

Given an array of  N integers, can you find the sum of its elements? In python

23rd Oct 2017, 6:51 PM
Rabi Raj
Rabi Raj - avatar
6 Answers
+ 4
a = [1,2,3,4,5] print(sum(a))
23rd Oct 2017, 7:15 PM
Ankit Agrawal
Ankit Agrawal - avatar
+ 3
Sample Input: 1 2 3 4 5 Sample Output: Sum of elements is 15 https://code.sololearn.com/c096pcZS24J2/?ref=app
23rd Oct 2017, 7:33 PM
Ankit Agrawal
Ankit Agrawal - avatar
+ 1
You can do it with a loop, while or for
23rd Oct 2017, 7:23 PM
Daniel
Daniel - avatar
+ 1
incase if it is random integer
23rd Oct 2017, 7:28 PM
Rabi Raj
Rabi Raj - avatar
0
actually I want to know how to provide input in array
23rd Oct 2017, 7:19 PM
Rabi Raj
Rabi Raj - avatar
0
No problem with random, you only must to generate it before a loop
23rd Oct 2017, 7:36 PM
Daniel
Daniel - avatar