python编写函数,随机产生20个两位的正整数存入列表ls中,返回列表中低于平均值的数有多少?

输出该函数结果,一定要是python,求详细截图

#!/usr/bin/python3
# -*- coding:utf-8 -*-
"""
@author:Strom_duck
@file  :20200622_01.py
@time  :2020/6/22 13:47
"""

"""
随机产生20个两位的正整数存入列表ls中,返回列表中低于平均值的数有多少
"""

if __name__ == "__main__":
from random import randint as rd
olist = []
for i in range(20):
olist.append(rd(10, 99))
avg = sum(olist) / 20
result_list = [t for t in olist if t < avg]

print("小于平均值的数有{}个".format(len(result_list)))
print("小于平均数的是:{}".format(result_list))

温馨提示:答案为网友推荐,仅供参考