返回列表 發帖

if...elif...else

本帖最後由 tonyh 於 2022-1-27 10:04 編輯

  1. score=input("請輸入你的成績: ")
  2. score=float(score)
  3. if score>100:
  4.     print("輸入錯誤~斬!")
  5. elif score>=90:
  6.     print("優")  
  7. elif score>=80:
  8.     print("甲")
  9. elif score>=70:
  10.     print("乙")
  11. elif score>=60:
  12.     print("丙")
  13. elif score>=0:
  14.     print("不及格")
  15. else:
  16.     print("輸入錯誤~斬!")
複製代碼
  1. score=input("請輸入你的成績: ")
  2. score=float(score)
  3. if score>=90 and score<=100:  #多擇一
  4.     print("優")
  5. elif score>=80 and score<90:
  6.     print("甲")
  7. elif score>=70 and score<80:
  8.     print("乙")
  9. elif score>=60 and score<70:
  10.     print("丙")
  11. elif score>=0 and score<60:
  12.     print("不及格")
  13. else:
  14.     print("輸入錯誤~斬!")
複製代碼
  1. score=input("請輸入你的成績: ")
  2. score=float(score)
  3. if(score>=90 and score<=100):
  4.     print("優等!")
  5. elif(score>=80 and score<90):
  6.     print("甲等!")
  7. elif(score>=70 and score<80):
  8.     print("乙等!")
  9. elif(score>=60 and score<70):
  10.     print("丙等!")
  11. elif(score>=0 and score<60):
  12.     print("不及格!")
  13. else:
  14.     print("輸入錯誤!")
複製代碼

  1. score=input("請輸入你的成績: ")
  2. score=float(score )
  3. if(score>=90 and score<=100):
  4.     print("優等!")
  5. elif(score>=80 and score<90):
  6.     print("甲等!")
  7. elif(score>=70 and score<80):
  8.     print("乙等!")
  9. elif(score>=60 and score<70):
  10.     print("丙等!")
  11. elif(score>=0 and score<60):
  12.     print("不及格~")
  13. else:
  14.     print("輸入錯誤!")

  15.      
複製代碼

TOP

  1. score=input("請輸入你的成績:")
  2. score=float(score )
  3. if(score>=100 and score<=100):
  4.     print("你可以去考門薩了")
  5. elif(score>=90 and score<100 ):
  6.     print("優等!")
  7. elif(score>=80 and score<90):
  8.     print("甲等!")
  9. elif(score>=70 and score<80):
  10.     print("乙等!")
  11. elif(score>=60 and score<70):
  12.     print("丙等!")
  13. elif(score>=30 and score<60):
  14.     print("不及格~")
  15. elif(score>=0 and score<30):
  16.     print("你需要去讀啟智學校")
  17. elif(score>=101 and score<300):
  18.     print("你腦子壞了")
  19. else:
  20.     print("給我去精神病院")
複製代碼

TOP

  1. score=(input("請輸入你的成績"))
  2. score=float(score)
  3. if score>=90 and score<=100:
  4.     print("優等")
  5. elif score>=80 and score<90:
  6.     print("甲等")
  7. elif score>=70 and score<80:
  8.     print("乙等")
  9. elif score>=60 and score<70:
  10.     print("丙等")
  11. elif score>=0 and score<60:
  12.     print("不及格")
  13. else:
  14.     print("輸入錯誤~斬!")
複製代碼

TOP

  1. score=float(input("請輸入成績:"))
  2. if score>=90 and>=100:
  3.     print("優")   
  4. elif score>=80 and>90:
  5.     print("甲")
  6. elif score>=70 and>80:
  7.     print("乙")
  8. elif  score>=60 and>70:
  9.     print("丙")
  10. elif  score>=0 and>:60
  11.     print("不及格")
  12. else
  13.     print("輸入錯誤~斬")
複製代碼

TOP

  1. score=input("請輸入你的成績: ")
  2. score=float(score )
  3. if(score>=90 and score<=100):
  4.     print("優等!")
  5. elif(score>=80 and score<90):
  6.     print("甲等!")
  7. elif(score>=70 and score<80):
  8.     print("乙等!")
  9. elif(score>=60 and score<70):     
  10.     print("丙等!")
  11. elif(score>=0 and score<60):
  12.     print("不及格~哈哈哈")
  13. else:
  14.     print("輸入錯誤!~笑死你")
複製代碼

TOP

本帖最後由 林柏諺 於 2022-1-27 09:55 編輯
  1. score=input("請輸入你的成績: ")
  2. score=float(score)
  3. if score>=90 and score<=100:
  4. print("優等!")
  5. elif score>=80 and score<90:
  6. print("甲等!")
  7. elif score>=70 and score<80:
  8. print("乙等!")
  9. elif score>=60 and score<70:
  10. print("丙等!")
  11. elif score>=0 and score<60:
  12. print("不及格!")
  13. else:
  14. print("輸入錯誤!")
複製代碼

TOP

  1. score=input("請輸入你的成績:")
  2. score=float(score)


  3. if score>=90 and score<=100:
  4.     print("優等")
  5.    
  6. elif score>80 and score<90:
  7.     print("甲等")

  8. elif score>70 and score<80:
  9.     print("乙等")

  10. elif score>60 and score<70:
  11.     print("丙等")

  12. elif score>0 and score<60:
  13.     print("不及格")

  14. else:
  15.     print("輸入錯誤!!!")
  16.    
複製代碼

TOP

  1. score=input("請輸入你的成績: ")
  2. score=float(score )
  3. if(score>=90 and score<=100):
  4.     print("優等!")
  5. elif(score>=80 and score<90):
  6.     print("甲等!")
  7. elif(score>=70 and score<80):
  8.     print("乙等!")
  9. elif(score>=60 and score<70):
  10.     print("丙等!")
  11. elif(score>=0 and score<60):
  12.     print("不及格~")
  13. else:
  14.     print("輸入錯誤!")
複製代碼

TOP

返回列表