Board logo

標題: if...elif...else [打印本頁]

作者: tonyh    時間: 2022-6-30 15:59     標題: if...elif...else

本帖最後由 tonyh 於 2022-6-30 16:15 編輯

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

作者: 李沛昂    時間: 2022-6-30 16:15

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

作者: 王捷恩    時間: 2022-6-30 16:20

  1. score = eval(input("enter your score: "))
  2. if score >= 90 and score <= 100:
  3.     print("a")
  4. elif score >= 80 and score < 90:
  5.     print("b")
  6. elif score >= 70 and score < 80:
  7.     print("c")
  8. elif score >= 60 and score < 70:
  9.     print("d")
  10. elif score < 60 and score >= 0:
  11.     print("did not pass")
  12. else:
  13.     print("invalid")
複製代碼

作者: 李沛昂    時間: 2022-6-30 16:24

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

作者: 王捷恩    時間: 2022-6-30 16:28

  1. score = eval(input("enter your score: "))
  2. if score >= 90:
  3.     print("a")
  4. elif score >= 80:
  5.     print("b")
  6. elif score >= 70:
  7.     print("c")
  8. elif score < 60:
  9.     print("did not pass")
  10. elif score > 100:
  11.     print("invalid")
  12. elif score < 0:
  13.     print("invalid")
複製代碼





歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/) Powered by Discuz! 7.2