继续收到错误报告
文件“/home/hilld5/DenicaHillPP4.py”,第 72 行,在 maingradeReport =gradeReport +“\n”+ studentName +“:\t%6.1f”%studentScore+“\t”+studentGrade TypeError: cannot concatenate 'str ' 和 'NoneType' 对象
但似乎无法弄清楚为什么学生成绩没有返回
studentName = ""
studentScore = ""
def getExamPoints (total): #calculates Exam grade
total = 0.0
for i in range (4):
examPoints = input ("Enter exam " + str(i+1) + " score for " + studentName + ": ")
total += int(examPoints)
total = total/.50
total = total * 100
return total
def getHomeworkPoints (total):#calculates homework grade
total = 0.0
for i in range (5):
hwPoints = input ("Enter homework " + str(i+1) + " score for " + studentName + ": ")
total += int(hwPoints)
total = total/.10
total = total * 100
return total
def getProjectPoints (total): #calculates project grade
total = 0.0
for i in range (3):
projectPoints = input ("Enter project " + str(i+1) + " score for " + studentName + ": ")
total += int(projectPoints)
total = total/.40
total = total * 100
return total
def computeGrade (total): #calculates grade
if studentScore>=90:
grade='A'
elif studentScore>=80 and studentScore<=89:
grade='B'
elif studentScore>=70 and studentScore<=79:
grade='C'
elif studentScore>=60 and studentScore<=69:
grade='D'
else:
grade='F'
def main ( ):
classAverage = 0.0 # initialize averages
classAvgGrade = "C"
studentScore = 0.0
classTotal = 0.0
studentCount = 0
gradeReport = "\n\nStudent\tScore\tGrade\n============================\n"
studentName = raw_input ("Enter the next student's name, 'quit' when done: ")
while studentName != "quit":
studentCount = studentCount + 1
examPoints = getExamPoints (studentName)
hwPoints = getHomeworkPoints (studentName)
projectPoints = getProjectPoints (studentName)
studentScore = examPoints + hwPoints + projectPoints
studentGrade = computeGrade (studentScore)
gradeReport = gradeReport + "\n" + studentName + ":\t%6.1f"%studentScore+"\t"+studentGrade
classTotal = classTotal + studentScore
studentName = raw_input ("Enter the next student's name, 'quit' when done: ")
print gradeReport
classAverage = int ( round (classTotal/studentCount) )
# call the grade computation function to determine average class grade
classAvgGrade = computeGrade ( classAverage )
print "Average class score: " , classAverage, "\nAverage class grade: ", classAvgGrade
main ( ) # Launch