月份的天数问题】
给定某年某月,编程,输出这个月的天数:
例如:
输入:2004 2
输出:2004年2月的天数是29天。
月份的天数问题】
给定某年某月,编程,输出这个月的天数:
例如:
输入:2004 2
输出:2004年2月的天数是29天。
year = int(input('Year:'))
month = int(input('Month:'))
if (month == 1 or month == 3 or month == 5 or month == 7 or month == 8 or month == 10 or month == 12):
print('31天')
elif (month == 4 or month == 6 or month == 9 or month == 11 ):
print('30天')
elif month == 2 and ((year % 4==0 and year % 100!=0) or (year % 400==0)):
print('29天')
else:
print('28天')
有帮助的话采纳一下哦!