1. 定义一个函数实现针对姓名进行查询的操作,显示学生的基本信息
def searchStudent(stuName):for stu in stuInfo:if stuName == stu[1]:print(stu)
2. 定义一个统计函数,对班级学生的身高进行统计,显示平均身高,最大身高,最小身高 def static(sex=’’),
# 如果传递的实参是Male或者Female,就分别统计,如果没有传递性别实参,就统计所有人
def static(sex=''):height = []findflag = Falsefor stu in stuInfo:if sex.lower() == stu[3].lower():height.append(stu[2])else:if sex=='':height.append(stu[2])avgHeight = sum(height) / len(height)print(f'平均身高:{avgHeight:.2f}最大身高:{max(height)}最小身高{min(height)}')while True:choice = input('请输入性别:')if choice.lower() in ('','male','female'):static(choice)else:print('请输入正确的选项')
