標題:
if...elif...else
[打印本頁]
作者:
tonyh
時間:
2022-6-30 15:59
標題:
if...elif...else
本帖最後由 tonyh 於 2022-6-30 16:15 編輯
score=eval(input("請輸入你的成績: "))
if score>=90 and score<=100:
print("優等!")
elif score>=80 and score<90:
print("甲等!")
elif score>=70 and score<80:
print("乙等!")
elif score>=60 and score<70:
print("丙等!")
elif score>=0 and score<60:
print("不及格!")
else:
print("輸入錯誤!")
複製代碼
score=eval(input("請輸入你的成績: "))
if score>100:
print("輸入錯誤!")
elif score>=90:
print("優等!")
elif score>=80:
print("甲等!")
elif score>=70:
print("乙等!")
elif score>=60:
print("丙等!")
elif score>=0:
print("不及格!")
else:
print("輸入錯誤!")
複製代碼
作者:
李沛昂
時間:
2022-6-30 16:15
score=eval(input("請輸入你的成績: "))
if score>=90 and score<=100:
print("優等")
elif score>=80 and score<90:
print("甲等")
elif score>=70 and score<80:
print("乙等")
elif score>=60 and score<70:
print("優等")
elif score>=0 and score<60:
print("不及格")
else:
print("輸入錯誤")
複製代碼
作者:
王捷恩
時間:
2022-6-30 16:20
score = eval(input("enter your score: "))
if score >= 90 and score <= 100:
print("a")
elif score >= 80 and score < 90:
print("b")
elif score >= 70 and score < 80:
print("c")
elif score >= 60 and score < 70:
print("d")
elif score < 60 and score >= 0:
print("did not pass")
else:
print("invalid")
複製代碼
作者:
李沛昂
時間:
2022-6-30 16:24
score=eval(input("請輸入你的成績: "))
if score>100:
print("輸入錯誤")
elif score>=90:
print("優等")
elif score>=80:
print("甲等")
elif score>=70:
print("乙等")
elif score>=60:
print("優等")
elif score>=0:
print("不及格")
else:
print("輸入錯誤")
複製代碼
作者:
王捷恩
時間:
2022-6-30 16:28
score = eval(input("enter your score: "))
if score >= 90:
print("a")
elif score >= 80:
print("b")
elif score >= 70:
print("c")
elif score < 60:
print("did not pass")
elif score > 100:
print("invalid")
elif score < 0:
print("invalid")
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2