1.声明一个字典保存一个学生的信息,学生信息中包括: 姓名、年龄、成绩(单科)、电话
student1_massage = {'name': '王', 'age': '19', 'grade': '88', 'tell_num': '13257668903'}
print(student1_massage)
# 2.声明一个列表,在列表中保存6个学生的信息(6个题1中的字典)
student1_massage = {'name': '王', 'age': '19', 'grade': '88', 'tell_num': '13257667903'}
student2_massage = {'name': '陈', 'age': '19', 'grade': '86', 'tell_num': '13257667908'}
student3_massage = {'name': '郭', 'age': '17', 'grade': '55', 'tell_num': '13257448903'}
student4_massage = {'name': '梁', 'age': '19', 'grade': '67', 'tell_num': '13257666908'}
student5_massage = {'name': '朱', 'age': '16', 'grade': '99', 'tell_num': '13257633903'}
student6_massage = {'name': '黄', 'age': '19', 'grade': '75', 'tell_num': '13252268903'}
six_student = (student1_massage, student2_massage, student3_massage, student4_massage, student5_massage,student6_massage)
[print(six_student)]
a.统计不及格学生的个数
count = 0
for student in six_student:
for key in student:
if key == 'grade':
if int(student[key]) < 60:
count += 1
print(count)
b.打印不及格学生的名字和对应的成绩
for student in six_student:
for key in student:
if key == 'grade':
if int(student[key]) < 60:
print(student['name'], student[key])
c.统计未成年学生的个数
count = 0
for student in six_student:
for key in student:
if key == 'age':
if int(student[key]) < 8:
count += 1
print('未成年学生的个数:', count)
d.打印手机尾号是8的学生的名字
count = 0
for student in six_student:
for key in student:
if key == 'tell_num':
if int(student[key][-1]) == 8:
print(student['name'])
e.打印最高分和对应的学生的名字
countine