如何让python添加一个字符串?

2024-10-17 06:18:08 发布

您现在位置:Python中文网/ 问答频道 /正文

下面是我的一小段代码:

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)。你知道吗


Tags: 字符串代码inforinputdefrangetotal
2条回答

你试过了吗

total += int(examPoints);

无任何错误检查错误输入:

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

相关问题 更多 >