Skip to content

Commit 9c9d9bd

Browse files
huntober challenge oct 24
1 parent 91cdbee commit 9c9d9bd

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

huntober2023/oct24.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# It's the academic year's end, fateful moment of your school report. The averages must be calculated. All the students come to you and entreat you to calculate their average for them. Easy ! You just need to write a script.
2+
3+
# Return the average of the given array rounded down to its nearest integer.
4+
5+
# The array will never be empty.
6+
7+
# getAverage([2,2,2,2]),2)
8+
# getAverage([1,2,3,4,5,]),3);
9+
# getAverage([1,1,1,1,1,1,1,2]),1)
10+
11+
# given array input
12+
# return average rounded down to its nearest integer
13+
# get sum of all elements in list
14+
# get the length
15+
# return the integer while rounding
16+
def getAverage(arr):
17+
return int(sum(arr) / len(arr))
18+
19+
print(getAverage([2,2,2,2]), 2)
20+
print(getAverage([1,2,3,4,5]), 3)
21+
print(getAverage([1,1,1,1,1,1,1,2]), 1)

0 commit comments

Comments
 (0)