
TQC+ 程式語言Python 205 字元判斷
題目說明:
請使用選擇敘述撰寫一程式,讓使用者輸入一個字元,判斷它是包括大、小寫的英文字母(alphabet)、數字(number)、或者其它字元(symbol)。例如:a為英文字母、9為數字、$為其它字元。
範例輸入1
P
範例輸出1
P is an alphabet.
範例輸入2
@
範例輸出2
@ is a symbol.
範例輸入3
7
範例輸出3
7 is a number.
程式碼:
s = input()
if s >= 'A' and s <= 'Z' or s >= 'a' and s <= 'z':
print('%s is an alphabet.' %s)
elif s >= '0' and s <= '9':
print('%s is a number.' %s)
else:
print('%s is a symbol.' %s)
TQC+ 程式語言Python 第2類:選擇敘述

如果覺得文章內容還不錯的話,麻煩請幫我點個讚!感謝
可以多點幾次喔~~
第一次點讚需使用 Google 或 Facebook 帳號註冊

