python test4:输入某年某月某日,判断这一天是这一年的第几天?

year = int(raw_input('please input year: '))
month = int(raw_input('please input month: '))
day = int(raw_input('please input day: '))

months = (0,31,59,90,120,151,181,212,243,273,304,334)

sum = 0

if  3<=month<=12:

        if (year % 4 ==0 and year % 100 != 0) or (year % 400 == 0):
           sum = months[month-1]+1
           #days = sum + day
           day += sum
           print day
        else:
            sum = months[month-1]
            day += sum

            print ("it is the %dth day" % day)
else:
    print "the month is valid!"

if 0 
 

你可能感兴趣的:(python test4:输入某年某月某日,判断这一天是这一年的第几天?)