Skip to content

Commit 544bf00

Browse files
Add files via upload
1 parent fd8b2ef commit 544bf00

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Average of an array.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Python3 code to calculate
2+
# average of array elements
3+
4+
# Function that return
5+
# average of an array.
6+
def average( a , n ):
7+
8+
# Find sum of array element
9+
sum = 0
10+
for i in range(n):
11+
sum += a[i]
12+
13+
return sum/n;
14+
15+
# array
16+
arr = [10, 2, 3, 4, 5, 6, 7, 8, 9]
17+
n = len(arr)
18+
print("The average of the array is:",average(arr, n))
19+
20+
# by aditya

0 commit comments

Comments
 (0)