返回列表 發帖

if...elif...else

本帖最後由 陳品肇 於 2020-2-2 09:58 編輯


90~100 優等
80~89 甲等
70~79 乙等
60~69 丙等
0~59 不及格
其餘輸入錯誤!!

本帖隱藏的內容需要回復才可以瀏覽
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

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

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

TOP

  1. a=int(input("請輸入成績: "))
  2. if(a<=100 and a>=90):
  3.     print("優等")
  4. elif(a<90 and a>=80):
  5.     print("甲等")
  6. elif(a<=79 and a>=60):
  7.     print("乙等")
  8. elif(a<60 and a>=0):
  9.     print("不及格")
  10. else:
  11.     print("輸入錯誤!")
複製代碼
陳頡鴻

TOP

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

TOP

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

TOP

  1. score = int(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("輸入錯誤!")
複製代碼

TOP

  1. # -*- coding: utf-8 -*-

  2. score=int(input("請輸入分數"))

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

TOP

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

TOP

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

TOP

  1. score=int(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("輸入錯誤!")
複製代碼

TOP

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

TOP

  1. # -*- coding: utf-8 -*-
  2. """
  3. Spyder Editor

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

TOP

  1. score =int(input("請輸入分數:"))
  2. if(score>=90and 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("輸入錯誤")
複製代碼

TOP

  1. score=int(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("輸入錯誤!")
複製代碼

TOP

返回列表