標題:
if...elif...else
[打印本頁]
作者:
tonyh
時間:
2022-3-26 15:31
標題:
if...elif...else
本帖最後由 tonyh 於 2022-3-26 16:19 編輯
score=float(input("請輸入你的成績: "))
if score>100 or score<0:
print("輸入錯誤")
elif score>=90:
print("優")
elif score>=80:
print("甲")
elif score>=70:
print("乙")
elif score>=60:
print("丙")
else:
print("不及格")
複製代碼
score=float(input("請輸入你的成績: "))
if 90<=score<=100:
print("優")
elif 80<=score<90:
print("甲")
elif 70<=score<80:
print("乙")
elif 60<=score<70:
print("丙")
elif 0<=score<60:
print("不及格")
else:
print("輸入錯誤")
複製代碼
score=float(input("請輸入你的成績: "))
if score>=90<=100:
print("優")
elif score>=80<90:
print("甲")
elif score>=70<80:
print("乙")
elif score>=60<70:
print("丙")
elif score>=0<60:
print("不及格")
else:
print("輸入錯誤")
複製代碼
score=input("請輸入你的成績: ")
score=float(score)
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-3-26 16:14
score = float(input("Input Score: "))
if (90 <= score <= 100):
print("A++")
elif (score >90<=80):
print("A+")
elif (score >80<=70):
print("A")
elif (score >70<=60):
print("B")
elif (score <60>=0):
print("C")
else:
print("Failed")
複製代碼
作者:
郭詩瑜
時間:
2022-3-26 16:28
score = float(input("Input Score: "))
if (score < 0 or score > 100):
print("Failed")
elif (score >= 90):
print("A++")
elif (score >= 80):
print("A+")
elif (score >= 70):
print("A")
elif (score >= 60):
print("B")
else:
print("C")
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2