这是我的一小部分代码:
studentName = ""
def getExamPoints (total):
for i in range (4):
total = 0.0
examPoints = input ("Enter exam score for " + studentName + str(i+1) + ": ")
total = ?????
total = total/.50
total = total * 100
哪里有?????是我无法弄清楚如何让字符串添加四个分数
学生姓名我稍后提出,并且要求我在程序的后期使用examPoints = getExamPoints(studentName)
。
答案 0 :(得分:1)
没有错误检查输入错误:
total = 0.0
for i in range (4):
total += int(input ("Enter exam score for " + studentName + str(i+1) + ": "))
total = total/.50
total = total * 100
答案 1 :(得分:1)
你试过吗
total += int(examPoints);