【发布时间】:2022-01-24 07:52:03
【问题描述】:
a= int(input("Enter number of students:"))
i=1
n = []
t = []
p = []
avg = []
while i<=a:
total=0
name = input("Enter name of student:")
n.append(name)
subjects = int(input("Enter count of subjects:"))
i=i+1
j=1
while j<=subjects:
s = int(input("Enter marks:"))
total = total + s
j=j+1
percentage = (total/(subjects*100))*100
average = total/subjects
t.append(total)
p.append(percentage)
avg.append(avg)
result = dict(zip(n,p))
print("Total marks of", name, "is", total)
print("The students:",n)
print("The total of students:",total)
print("The average of students:",avg)
print("The percentage of students:", percentage)
print("The result of students:", result)
我想存储从这段代码中获得的数据,然后显示特定数据,例如如果我搜索学生的姓名,我会得到他的分数和平均分。我该怎么做?
【问题讨论】:
-
最好能详细说明你遇到了什么问题,解决什么问题,预期的输出是什么。否则,用户应该花很多时间来理解您的问题。
-
您的意思是将结果字典存储在文件中吗?
-
如果您想稍后存储和使用字典,不妨看看这个:stackoverflow.com/questions/11218477/…。
标签: python dictionary