python隨筆---錄入月份的值,輸出對應的季節

來源:互聯網
上載者:User

標籤:夏天   http   輸出   根據   for   orm   code   圖片   並且   

 首先擷取一個輸入,加判斷,輸入對應的月份,季節判定根據氣象劃分法(氣象劃分法:在氣象部門,通常以陽曆3~5月為春季,6~8月為夏季,9~11月為秋季,12月~來年2月為冬季,並且常常把1、4、7、10月作為冬、春、夏、秋季的代表月份)

以下為弱基礎小白實現代碼:

month = int(input("請輸入月份:"))if month >= 3 and month <= 5:    print("你輸入的{}月份是春天".format(month))elif month >= 6 and month <= 8:    print("你輸入的{}月份是夏天".format(month))elif month >= 9 and month <= 11:    print("你輸入的{}月份是秋天".format(month))elif month ==12 or month == 1 or month == 2 :    print("你輸入的{}月份是冬天".format(month))else:    print("月份輸入不規範,請重新輸入!")

有任何錯誤和不足的地方,請在下面留言指正!謝謝

   

 

 

python隨筆---錄入月份的值,輸出對應的季節

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.