码迷,mamicode.com
首页 > 编程语言 > 详细

(Python第三天)实例

时间:2019-01-16 22:49:19      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:app   nts   生成   The   data   分数   int   实例   name   

一、判断学生成绩是否达标的程序

 1 n = int(input("Enter the number of students:"))#输入学生数目
 2 data = {}   #用来存储数据的字典变量
 3 Subjects = (Physics,Maths,History) #元组,定义所有科目
 4 for i in range(0,n):
 5     name = input(Enter the name of the student {}:.format(i + 1))#获得学生名称
 6     marks = []
 7     for x in Subjects:
 8         marks.append(int(input(Enter marks of {}:.format(x))))#获得分数
 9     data[name] = marks#把分数存储到data中
10     for x,y in data.items():
11         total = sum(y)
12         print("{}‘s total marks {}".format(x,total))
13         if total < 120:
14             print(x,"failes :(")
15         else:
16             print(x, "passed :)")

 

(Python第三天)实例

标签:app   nts   生成   The   data   分数   int   实例   name   

原文地址:https://www.cnblogs.com/ywangji/p/10279660.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!