1. 定义一个函数实现针对姓名进行查询的操作,显示学生的基本信息

    1. def searchStudent(stuName):
    2. for stu in stuInfo:
    3. if stuName == stu[1]:
    4. print(stu)

    2. 定义一个统计函数,对班级学生的身高进行统计,显示平均身高,最大身高,最小身高 def static(sex=’’),
    # 如果传递的实参是Male或者Female,就分别统计,如果没有传递性别实参,就统计所有人

    1. def static(sex=''):
    2. height = []
    3. findflag = False
    4. for stu in stuInfo:
    5. if sex.lower() == stu[3].lower():
    6. height.append(stu[2])
    7. else:
    8. if sex=='':
    9. height.append(stu[2])
    10. avgHeight = sum(height) / len(height)
    11. print(f'平均身高:{avgHeight:.2f}最大身高:{max(height)}最小身高{min(height)}')
    12. while True:
    13. choice = input('请输入性别:')
    14. if choice.lower() in ('','male','female'):
    15. static(choice)
    16. else:
    17. print('请输入正确的选项')