1453544851 发表于 2024-12-27 11:55:49

python

score = input("请输入你的分数:")

score = int(score)



if score < 60:

    print("D")

   

if 60 <= score < 80:

    print("C")



if 80 <= score < 90:

    print("B")



if 90 <= score < 100:

    print("A")



if score == 100:

    print("S")
   
SyntaxError: multiple statements found while compiling a single statement   请问这样输入为什么会报错啊

FishC 发表于 2024-12-27 11:56:03

score = input("请输入你的分数:")

score = int(score)

if score < 60:
    print("D")
elif 60 <= score < 70:
    print("C")
elif 70 <= score < 80:
    print("B")
elif 80 <= score < 90:
    print("A")
else:
    print("A+")

这个Python代码用于根据分数输出相应的等级。注意使用`elif`语句来检查不同的分数范围,从而避免多个条件同时生效的问题。

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。

tommyyu 发表于 2024-12-27 12:57:05

你不能直接输进 IDLE 里面,得新建文件,保存,运行。参考 https://fishc.com.cn/thread-142729-1-1.html。

1453544851 发表于 2024-12-27 16:06:22

tommyyu 发表于 2024-12-27 12:57
你不能直接输进 IDLE 里面,得新建文件,保存,运行。参考 https://fishc.com.cn/thread-142729-1-1.html ...

感谢
页: [1]
查看完整版本: python