首页 > 代码库 > python练习程序(c100经典例4)

python练习程序(c100经典例4)

题目:

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

def judge_run(year):    a=year/4.0;    b=year/100.0;    c=year/400.0;    if a==int(a) and b!=int(b):        return 1    if c==int(c):        return 1    return 0def judge_day(year,month,day):    m1=[31,28,31,30,31,30,31,31,30,31,30,31];    y=judge_run(year);    m=0;    for i in range(0,month-1):        m=m+m1[i];    if month>2:        m=m+y;    return m+day;print judge_day(2014,9,12)

 

python练习程序(c100经典例4)