使用函数显示用户输入的每个测试分数的分数

时间:2018-02-03 20:20:58

标签: python-3.x

我希望通过Python中的一个函数发送5个测试分数,并让该函数为每个函数显示一个字母等级。我也得到了这些分数的平均值。这是我到目前为止:

testscore1 = float(input('Enter first test score: '))

testscore2 = float(input('Enter second test score: '))

testscore3 = float(input('Enter third test score: '))

testscore4 = float(input('Enter fourth test score: '))

testscore5 = float(input('Enter fifth test score: '))

listofscores = (testscore1,testscore2,testscore3,testscore4,testscore5)

def calcAverage():
  average = (testscore1+testscore2+testscore3+testscore4+testscore5)/5
  return average

def determineGrade(listofscores):
  for i in listofscores
  testscore1 = round(testscore1)
  if listofscores > 100:
      return "please enter a real score"
  elif listofscores <= 100 and listofscores >=90:
      return "your grade is an A"
  elif listofscores >= 80 and listofscores <= 89:
      return "your grade is a B"
  elif listofscores >= 70 and listofscores <= 79:
      return "your grade is a C"
  elif listofscores >= 60 and listofscores <= 69:
      return "your grade is a D"
  elif listofscores < 60: 
      return "your grade is an F"


print(determineGrade(),calcAverage())

如何将所有分数传递到成绩函数并显示每个分数的每个分数?

1 个答案:

答案 0 :(得分:0)

这里

     determineGrade(testscore1)
Should be:
     determineGrade(listofscores)