#coding = Utf-8defgetlastday (): Y= Int (Input ("Please input year:")) M= Int (Input ("Please input month:")) d= Int (Input ("Please input day:")) S=0ifY <1: Y=1ifM <1: M=1ifM>12: M=12ifD <1: D=1Mothday=[31,28,31,30,31,30,31,31,30,31,30,31]#number of days per month in a yearMONTH=MOTHDAY[M-1]#get the number of days to enter a month ifD > Mothday[m-1]:#determine if the input date is greater than the number of monthsD=d-mothday[m-1] M+=1Month=MOTHDAY[M-1]#enter days greater than the number of days after month plus one, recalculate Crescent days ifM>12: M=12defRunnian (y,s):#determine if a leap yeart=0if(y%400) = =0:Print "is a leap year"T=1s+=1#if it is a leap year plus 1 days elif(y%100)!=0 and(y%4) = =0:Print "is a leap year"T=1s+=1#if it is a leap year plus 1 days Else : Print "not a leap year"T=0 S=0returnt,s t,s=Runnian (y,s)ifm==2: Month= month +TPrintMonth#returns the number of days of the month forIinchRange (0,m-1): S= S+Int (mothday[i]) s=s+DPrintS#returns the date that is the number of days of the yearGetlastday ()
In Python, determine if a leap year is the first day