Chinaunix
标题:
关于if结构的问题
[打印本页]
作者:
Blue.tooth
时间:
2006-09-24 22:06
标题:
关于if结构的问题
别笑话我,我刚学习这个(也没编过程),刚接触python
我想问一下,下面我写的这个if-else-if 结构的代码,为什么不论我敲什么数值进去,始终只是显示“just passed",比如我填80,也是显示这句话,语法上是哪出错了呢? 请解释一下,谢谢
grade=raw_input("what's your grade?")
if grade>60:
print "just passed!"
else:
if grade<60:
print "you failed"
else:
if grade>90:
print "super!"
复制代码
作者:
3751
时间:
2006-09-24 22:48
提示:
作者被禁止或删除 内容自动屏蔽
作者:
eookoo
时间:
2006-09-25 00:12
你的 if-else-if 也寫錯了
# 把input 的字轉成整數類型,otherwise it is string type!!!
grade = int( raw_input("What's your grade? "))
if grade => 90:
print "Super"
elif grade >= 70 and grade < 90:
print "Good!"
elif grade >= 60 and grade < 70:
print "Just passed!"
else:
print "You failed!"
复制代码
[
本帖最后由 eookoo 于 2006-9-26 12:22 编辑
]
作者:
Blue.tooth
时间:
2006-09-26 16:22
谢谢,我看的太不仔细了,回家好好的看基础的部分
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2