ユーザにユーザ名とパスワードを要求するプログラムを作成しようとしています。ログインの詳細が正しい場合、プログラムは生徒の名前を尋ね、各トピックに1つずつ、3つのスコアを尋ねる必要があります。プログラムは、別の学生の詳細を入力するかどうかをユーザーに尋ねる必要があります。プログラムは、各トピックの平均スコアを出力する必要があります。私は学生一人一人の話題ごとに生徒標章を入力する方法と、そのクラスの各話題の平均をどのように計算するのかを考え出すことはできません。3つのトピックのマークの平均
助けてもらえますか?
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
は、各トピック(3つのトピック)の平均スコアを出力します。 – MrFHHH
topic_one_scores = [student_infoの学生のスコア[0] average_topic_one = sum(topic_one_scores)/ len(topic_one_scores)これは動作しません。 – MrFHHH