Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 三个主题的平均分数_Python_Dictionary_Average - Fatal编程技术网

Python 三个主题的平均分数

Python 三个主题的平均分数,python,dictionary,average,Python,Dictionary,Average,我正在尝试创建一个程序,要求用户输入用户名和密码。如果登录详细信息正确,程序应询问学生姓名,然后询问三个分数,每个主题一个分数。程序应询问用户是否希望输入其他学生的详细信息。程序应输出每个主题的平均分数。我无法计算如何输入每个学生每个主题的学生分数,以及如何计算班级每个主题的平均分数 你能帮忙吗 login="teacher" password="school" usrnm=input("Please enter your username: ") pw=input("Please enter

我正在尝试创建一个程序,要求用户输入用户名和密码。如果登录详细信息正确,程序应询问学生姓名,然后询问三个分数,每个主题一个分数。程序应询问用户是否希望输入其他学生的详细信息。程序应输出每个主题的平均分数。我无法计算如何输入每个学生每个主题的学生分数,以及如何计算班级每个主题的平均分数

你能帮忙吗

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!")

只要把分数和学生名字分开就行了

students = []
marks = []
option = ""
while (option != "No"):
    students.append(input("Name"))
    marks.append([float(input("Mark_Category1:")),
                  float(input("Mark_Category2:")),
                  float(input("Mark_Category3:"))])
    option = input("Add Another?")

import numpy
print(numpy.average(marks,0))
如果你真的不想numpy的话

averages = [sum(a)/float(len(a)) for a in zip(*marks)] # transpose our marks and average each column

您需要按主题或每个学生的分数跟踪平均分数吗?输出每个主题(三个主题)的平均分数。主题分数=[学生信息中学生的分数[0]平均主题分数=总和(主题分数)/len(主题分数)这不起作用。什么是numpy,因为我以前从未见过。numpy是一个广泛使用的数学库。。。你可以不用numpy很容易地做,但是用numpyThanks来介绍我更容易,但是你能告诉我没有numpy怎么做吗?在你要求我做的3分钟前,我提出了一种不用numpy的方法,在你被禁止使用numpy的6分钟前,我对此表示抱歉。我不明白这个简单的方法有多有效。你能帮我把这件事说清楚吗?