読み込んだ月の季節を表示 (論理演算子)

明解C言語 入門編 > 3. プログラムの流れと分岐 >

読み込んだ月の季節を表示 (論理演算子)

Python
# coding: Shift_JIS

month = int(raw_input("何月ですか:"))

if (3 <= month) and (month <= 5):
    print "春です。"
elif (6 <= month) and (month <= 8):
    print "夏です。"
elif (9 <= month) and (month <= 11):
    print "秋です。"
elif (month == 1) or (month == 2) or (month == 12):
    print "冬です。"
else:
    print "そんな月はありませんよ!!"

実行結果

N:\>python lesson_03_022.py
何月ですか:5
春です。

N:\>python lesson_03_022.py
何月ですか:8
夏です。