import statistics
if __name__ == '__main__': print("---------------------------求平均数------------------------------------") print("求[1,2,3,4,5.5]平均数:", statistics.mean([1, 2, 3, 4, 5.5])) print("求[1,2,3,4,5.5]平均数:", statistics.fmean([1, 2, 3, 4, 5.5])) print("---------------------------求中位数------------------------------------") print("求[1, 2, 3]中位数:", statistics.median([1, 2, 3])) print("求[1, 2, 3, 4]中位数:", statistics.median([1, 2, 3, 4])) print("求[1, 2, 3, 4]中位数:", statistics.median_low([1, 2, 3, 4])) print("求[1, 2, 3, 4]中位数:", statistics.median_high([1, 2, 3, 4])) print("---------------------------求频繁数------------------------------------") print("求[1,2,3,4,4]经常出现数:", statistics.mode([1, 2, 3, 4, 4])) print("求'abbbccc'经常出现数:", statistics.mode('abbbccc')) print("求[1,2,3,3,4,4]经常出现数:", statistics.multimode([1, 2, 3, 3, 4, 4])) print("求'abbbccc'经常出现数:", statistics.multimode('abbbccc'))
---------------------------求平均数------------------------------------ 求[1,2,3,4,5.5]平均数: 3.1 求[1,2,3,4,5.5]平均数: 3.1 ---------------------------求中位数------------------------------------ 求[1, 2, 3]中位数: 2 求[1, 2, 3, 4]中位数: 2.5 求[1, 2, 3, 4]中位数: 2 求[1, 2, 3, 4]中位数: 3 ---------------------------求频繁数------------------------------------ 求[1,2,3,4,4]经常出现数: 4 求'abbbccc'经常出现数: b 求[1,2,3,3,4,4]经常出现数: [3, 4] 求'abbbccc'经常出现数: ['b', 'c']
|