標題:
if...elif...else
[打印本頁]
作者:
鄭繼威
時間:
2023-7-7 19:34
標題:
if...elif...else
本帖最後由 鄭繼威 於 2023-7-10 15:51 編輯
多向判斷式語法
if (條件式一) :
程式區塊一
elif (條件式二):
程式區塊二
elif (條件式三):
程式區塊三
.........
else:
else的程式區塊
score=int(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("輸入錯誤!")
複製代碼
作者:
董恩瑞
時間:
2023-7-10 09:20
hihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihi
作者:
董炫霆
時間:
2023-7-10 16:01
score=input("輸入成績:")
score=int(score)
if score==100:
print("優等")
elif score>=90 and score<99:
print("甲等!")
elif score>=80 and score<89:
print("乙等!")
elif score>=70 and score<79:
print("丙等!")
elif score>=60 and score<69:
print("丁等!")
elif score>=0 and score<59:
print("不及格!")
else:
print("輸入錯誤")
複製代碼
作者:
歐陽霖
時間:
2023-7-10 16:01
本帖最後由 歐陽霖 於 2023-7-10 21:14 編輯
englishscore=int(input("請輸入英文成績:"))
chinesescore=int(input("請輸入國文成績:"))
mathscore=int(input("請輸入數學成績:"))
totalscore=englishscore+chinesescore+mathscore
print("總分:",totalscore)
totalscore=totalscore/3
print("平均分數為%.2f"%totalscore)
if totalscore==100:
print("優等!!")
elif totalscore>=90 and totalscore<100:
print("甲等!!")
elif totalscore>=80 and totalscore<90:
print("乙等!!")
elif totalscore>=70 and totalscore<80:
print("丙等!!")
elif totalscore>=60 and totalscore<70:
print("丁等!!")
elif totalscore>=0 and totalscore<60:
print("不及格!!")
else:
print("輸入錯誤!!")
複製代碼
作者:
劉恆
時間:
2023-7-10 16:04
總分=input("輸入成績:")
if 總分>60:
print("及格")
else:
print("不及格")
作者:
張育維
時間:
2023-7-10 16:05
k=input("Please enter Chinese score: ")
l=input("Please enter Math score: ")
m=input("Please enter English score: ")
print("Total= "+str(int(k)+int(l)+int(m)))
n=(int(k)+int(l)+int(m))/3
o="Average= %.2f"%n
print(o)
if float(o) or int(o)==100:
print("Excellent!")
elif:(float(o) or int(o) >=90) and (float(o) or int(o)<=99):
print("Great!")
elif:float(o) or int(o) >=80 and float(o) or int(o)<=89:
print("Awesome!")
elif:float(o) or int(o) >=70 and float(o) or int(o)<=79:
print("Good!")
elif:float(o) or int(o) >=60 and float(o) or int(o)<=69:
print("It's ok!")
elif:float(o) or int(o) >=0 and float(o) or int(o)<=59:
print("You can o it better!")
else:
print("You're wrong!")
複製代碼
(有Bug)
作者:
矯博宇
時間:
2023-8-2 15:51
a=int(input("輸入你的成績:"))
if a>=90 and a<=100:
print("優等")
elif a>=80 and a<90:
print("甲等")
elif a>=70 and a<80:
print("乙等")
elif a>=60 and a<70:
print("丙等")
elif a>=0 and a<60:
print("不及格")
else:
print("輸入已成績高於最大值")
複製代碼
作者:
呂宗晉
時間:
2023-8-2 15:52
score=int(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("輸入錯誤!")
複製代碼
作者:
盧承新
時間:
2023-8-2 15:54
a=int(input("請輸入成績:"))
if a==100:
print("優等")
elif a>=90 and a<=99:
print("甲等")
elif a>=80 and a<=89:
print("等")
elif a>=70 and a<=79:
print("丙等")
elif a>=60 and a<=69:
print("丁等")
elif a>=0 and a<=59:
print("不及格")
else:
print("錯誤")
複製代碼
作者:
得銓
時間:
2023-8-2 15:54
score=int(input("請輸入你的成績"))
if score>=90 and score<=100:
print("優等")
else if score>=80 and score<=90:
print("甲等")
else if score>=70 and score<=80:
print("乙等")
else if score>=60 and score<=70:
print("丙等")
else if score>=0 and score<=60:
print("不及格")
else:
print("輸入錯誤!")
複製代碼
作者:
鄧維成
時間:
2023-8-2 15:55
score=int(input("請輸入你的成績: "))
if score==100:
print("優等")
elif score>=90 and score<=99:
print("甲等")
elif score>=80 and score<=89:
print("乙等")
elif score>=70 and score<=79:
print("丙等")
elif score>=60 and score<=69:
print("丁等")
elif score<60:
print("不及格")
else:
print("輸入錯誤")
複製代碼
作者:
張絜晰
時間:
2023-8-2 15:55
a=int(input("What's your score?"))
if a>=90 and a<=100:
print("優等")
elif a>=80 and a<90:
print("甲等")
elif a>=70 and a<80:
print("乙等")
elif a>=60 and a<70:
print("丙等")
elif a>=0 and a<60:
print("不及格")
else:
print("what are you high on cuz i want some")
複製代碼
作者:
鄭繼威
時間:
2023-8-2 15:58
6
作者:
高士涵
時間:
2023-8-2 15:58
score=int(input("請輸入成績:"))
if score==100:
print("特優!!")
elif score>=90 and score<=99:
print("優等")
elif score>=80 and score<=89:
print("甲等")
elif score>=70 and score<=79:
print("乙等")
elif score>=60 and score<=69:
print("丙等")
elif score>=0 and score<=59:
print("丁等")
else:
print("錯誤")
複製代碼
作者:
盧芷萱
時間:
2023-8-2 15:59
score=input("請輸入你的成績:")
score=int(score)
if score==100:
print("優等")
elif score>=90 and score<=99:
print("甲等")
elif score>=80 and score<=89:
print("乙等")
elif score>=70 and score<=79:
print("丙等")
elif score>=60 and score<=69:
print("丁等")
else:
print("輸入錯誤")
複製代碼
作者:
張子搴
時間:
2023-8-2 16:01
score=int(input("請輸入成績:")
if score==100
print("優等")
elif score>=90 and score<=99:
print("甲")
elif score>=80 and score<=89
print("乙")
elif score>=70 and score<=79
print("丙")
elif score>=60 and score<=69
print("丁")
elif score>=0 and score<=59
print("不及格")
elso score>100 and score<0
print("1-100以外")
複製代碼
作者:
李逢翔
時間:
2023-8-2 16:03
name=input("請輸入姓名:")
score=int(int("請輸入成績:"))
if score==100:
print(f"{name} 你是天才!IQ180")
elif score>=90 and score<=99:
print(f"{name} 你是甲等")
elif score>=80 and score<=89:
print(f"{name} 你是乙等")
elif score>=70 and score<=79:
print(f"{name} 你是丙等")
elif score>=60 and score<=69:
print(f"{name} 你是丁等")
elif score>=0 and score<=59:
print(f"{name}!你不及格!滾!")
else:
print(f"{name}!你的成績輸入錯誤")
複製代碼
作者:
陳珺
時間:
2023-8-2 16:04
a=int(input("成績="))
if a<=100 and a>=90:
print("you")
elif a<=89 and a>=80:
print("jia")
elif a<=79 and a>=70:
print("乙等")
elif a<=69 and a>=60:
print("丙等")
elif a<=59 and a>=0:
print("不及格")
else:
print("輸入錯誤")
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2