if 條件式:
# 語句...
if 條件式:
# 語句...
else:
# 語句...
if 條件式 1:
# 語句...
elif 條件式 2:
# 語句...
if 條件式 1:
# 語句...
elif 條件式 2:
# 語句...
elif 條件式 3:
# 語句...
.
.
else:
# 語句...
score = int(input('請輸入分數 (1-100):'))
if score > 100:
print('請勿亂輸入!')
elif score >= 90 and score <= 100:
print('成績:A+')
elif score >= 80 and score < 90:
print('成績:B+')
elif score >= 70 and score < 80:
print('成績:B')
else:
print('成績:C')
輸出結果
請輸入分數 (1-100):60
成績:C
a = 22
b = 34
if a > b:
print("a is greater than b")
if a != b:
print("a is not equal to b")
輸出結果
a is not equal to b