Notice
Recent Posts
Recent Comments
Link
코드로 우주평화
Get the mean of an array 본문
반응형
Description:
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.
Return the average of the given array rounded down to its nearest integer.
The array will never be empty.
Solution:
1. Find the average.
2. Rounds down to an integer and returns it.
def get_average(marks):
import statistics
return statistics.mean(marks)//1
There are several ways to discard the decimal point. Among them, the simplest way to round off is to divide by 1 to get an integer value.
Although this method is not well introduced in the blog, it is a very simple and practical method.
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
Sort Numbers (0) | 2022.04.17 |
---|---|
Regex validate PIN code (0) | 2022.04.16 |
Sum of Odd Cubed Numbers (0) | 2022.04.14 |
Century From Year (0) | 2022.04.13 |
Isograms (0) | 2022.04.12 |