存储学生张三成绩的字典结构如下:\n\nstu={“name”:\"张三\",\"englisth\":80,\"python\":90,\"math\":100}\n\n(1)请使用上述结构输入5个学生的name及3门课的
时间: 2023-06-05 22:47:06 浏览: 580
Python语言基础项目案例:字典的操作.pptx
5星 · 资源好评率100%
成绩。
stu1={"name":"张三","english":80,"python":90,"math":100}
stu2={"name":"李四","english":85,"python":95,"math":90}
stu3={"name":"王五","english":75,"python":80,"math":95}
stu4={"name":"赵六","english":90,"python":85,"math":75}
stu5={"name":"钱七","english":95,"python":90,"math":80}
(2)请计算每个学生的总分和平均分。
stu1_total=stu1["english"]+stu1["python"]+stu1["math"]
stu1_avg=stu1_total/3
print("张三的总分为:",stu1_total,"平均分为:",stu1_avg)
stu2_total=stu2["english"]+stu2["python"]+stu2["math"]
stu2_avg=stu2_total/3
print("李四的总分为:",stu2_total,"平均分为:",stu2_avg)
stu3_total=stu3["english"]+stu3["python"]+stu3["math"]
stu3_avg=stu3_total/3
print("王五的总分为:",stu3_total,"平均分为:",stu3_avg)
stu4_total=stu4["english"]+stu4["python"]+stu4["math"]
stu4_avg=stu4_total/3
print("赵六的总分为:",stu4_total,"平均分为:",stu4_avg)
stu5_total=stu5["english"]+stu5["python"]+stu5["math"]
stu5_avg=stu5_total/3
print("钱七的总分为:",stu5_total,"平均分为:",stu5_avg)
阅读全文