题目:输入某年某月某日,判断这一天是这一年的第几天?
判断某一年是否是闰年方法:
-
能被4整除但不能被10整除
-
能被400整除
Dates = {} count_day = 0 Dates['year'] = int(input("please input the year:")) Dates['mouth'] = int(input("and the mouth:")) Dates['day'] = int(input("and the day:")) mouth = [1,2,3,4,5,6,7,8,9,10,11,12] day = [31,28,31,30,31,30,31,31,30,31,30,31] for i in range(13): if i < Dates['mouth'] - 1: count_day += day[i] elif i == Dates['mouth']: count_day += Dates['day'] if Dates['year'] % 4 == 0 and Dates['year'] % 10 != 0: count_day += 1 print(f"On {Dates['year']} - {Dates['mouth']} - {Dates['day']}") print(f"the year have passed {count_day}")
2415

被折叠的 条评论
为什么被折叠?



