实例004:这天是第几天python
题目 输入某年某月某日,判断这一天是这一年的第几天?编程
程序分析 特殊状况,闰年时需考虑二月多加一天:code
def isLeapYear(y): return (y%400==0 or (y%4==0 and y%100!=0)) DofM=[0,31,28,31,30,31,30,31,31,30,31,30] res=0 year=int(input('Year:')) month=int(input('Month:')) day=int(input('day:')) if isLeapYear(year): DofM[2]+=1 for i in range(month): res+=DofM[i] print(res+day) #解本问题有多种方法,此方法并非标准答案,读者能够本身尝试各类方法。
若是你喜欢个人文章,请滑到下方点个推荐再走. ,以给我动力哦;转载请注名出处。而后..请多来作客鸭。input
注:陆续会更新。欢迎你们在评论区分享出大家的方案让咱们一块儿进步。class