基于元组,根据月份,计算天数.(Python)
生活随笔
收集整理的這篇文章主要介紹了
基于元组,根据月份,计算天数.(Python)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
"""根據月份,計算天數.
"""# month = int(input("請輸入月份:"))
# if month < 1 or month > 12:
# print("輸入有誤")
# elif month == 2:
# print("28天")
# # elif month == 4 or month == 6 or month == 9 or month == 11:
# elif month in (4,6,9,11):
# print("30天")
# else:
# print("31天")
month = int(input("請輸入月份:"))
if month < 1 or month > 12:print("輸入有誤")
else:# 將每月的天數,存入元組.day_of_month = (31,28,31,30,31,30,31,31,30,31,30,31)print(day_of_month[month - 1])
輸出:
請輸入月份:6
30
總結
以上是生活随笔為你收集整理的基于元组,根据月份,计算天数.(Python)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 批量生成印刷字体字库
- 下一篇: 在控制台中输入月,日. 计算这是一年的