一、判断学生成绩是否达标的程序
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 :)")
原文:https://www.cnblogs.com/ywangji/p/10279660.html