我试图创建一个程序来询问用户的用户名和密码。如果登录详细信息是正确的,程序应询问学生姓名,然后要求三个分数,每个主题一个分数。该计划应询问用户是否希望输入其他学生的详细信息。该计划应输出每个主题的平均分数。我无法弄清楚如何为每个学生输入每个主题的学生分数,以及如何计算每个主题的平均分数。三个主题的标记平均值
你能帮忙吗?
login="teacher"
password="school"
usrnm=input("Please enter your username: ")
pw=input("Please enter your password: ")
if (usrnm==login) and (pw==password):
print("==Welcome to the Mathematics Score Entry Program==")
print("Do you want to enter the students score? Yes/No: ")
option = input()
option = option.title()
student_info = {}
student_data = ['Topic 1 : ', 'Topic 2 : ', 'Topic 3 : ']
while (option != "No"):
student_name = input("Name: ")
student_info[student_name] = {}
score1 = int(input("Please enter the score for topic 1: "))
student_info[student_name][Topic_1] = score1
score2 = int(input("Please enter the score for topic 2: "))
student_info[student_name][Topic_2] = score2
score3 = int(input("Please enter the score for topic 3: "))
student_info[student_name][Topic_3] = score3
print("Do you want to enter the students score? Yes/No: ")
option = input()
option = option.title()
average = sum(student_info.values())/len(student_info)
average = round(average,2)
print ("The average score is ", average)
else:
print("Access denied!")
你需要跟踪的主题的平均成绩,或每个学生的分数? – AllenMoh
输出每个主题的平均分数(三个主题)。 – MrFHHH
topic_one_scores = [学生信息中学生的分数[0]] average_topic_one =总和(topic_one_scores)/ len(topic_one_scores)这不起作用。 – MrFHHH