Quantcast
Channel: Finding the average of a list - Stack Overflow
Viewing all articles
Browse latest Browse all 26

Answer by Serhii Zelenchuk for Finding the average of a list

$
0
0

Simple solution is a avemedi-lib

pip install avemedi_lib

Than include to your script

from avemedi_lib.functions import average, get_median, get_median_customtest_even_array = [12, 32, 23, 43, 14, 44, 123, 15]test_odd_array = [1, 2, 3, 4, 5, 6, 7, 8, 9]# Getting average value of list itemsprint(average(test_even_array))  # 38.25# Getting median value for ordered or unordered numbers listprint(get_median(test_even_array))  # 27.5print(get_median(test_odd_array))  # 27.5# You can use your own sorted and your count functionsa = sorted(test_even_array)n = len(a)print(get_median_custom(a, n))  # 27.5

Enjoy.


Viewing all articles
Browse latest Browse all 26

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>