在python上运行以下命令

在python上运行以下命令,python,Python,尝试让程序输入学生姓名和分数,测试该程序以确保分数为变量>=0和=0: Name=原始输入(“学生的名字是什么?:”) 分数=浮动(原始输入(“学生的分数是多少?”)) 得分100分时: 打印(“错误:等级不能小于0或大于100”) 分数=浮动(原始输入(“学生的分数是多少?”)) gradeFile.write(名称+“\n”) gradeFile.write(分数+“\n”) gradeFile.close() 打印(“数据保存到grade.dat”) 您需要找到退出循环的方法。对于外部循环

尝试让程序输入学生姓名和分数,测试该程序以确保分数为变量>=0和=0: Name=原始输入(“学生的名字是什么?:”) 分数=浮动(原始输入(“学生的分数是多少?”)) 得分100分时: 打印(“错误:等级不能小于0或大于100”) 分数=浮动(原始输入(“学生的分数是多少?”)) gradeFile.write(名称+“\n”) gradeFile.write(分数+“\n”) gradeFile.close() 打印(“数据保存到grade.dat”)
您需要找到退出循环的方法。对于外部循环,您将自动进入。然后再次循环,直到通过内部循环得到有效分数,然后重复。在当前配置中,无法退出循环

此外,score应该是一个数字,但可以在
score=“0”
中以字符串形式输入。输出时,您需要编写
str(Score)
,以便将其与
“\n”
连接起来


我建议您的外部循环具有类似于
的内容,而Score>=0,userWantsToContinue
。您可以用任何您认为合适的方式处理
用户wantStocontinue

您的数据集不匹配

Score = "0"  # So, score is a string
while Score >= 0:  # Oh, thenm it's a integer?

gradeFile.write(分数+“\n”)为您提供错误
TypeError:不支持+:“float”和“str”的操作数类型
,您可以将其更改为gradeFile.write(分数)+“\n”)您没有问任何问题。关于你的任务,你需要回答什么问题?
Score = "0"  # So, score is a string
while Score >= 0:  # Oh, thenm it's a integer?