exercise002_判断闰年

#coding=utf-8
# 2:输入一个年份,输出是否为闰年 #闰年条件:能被4整除但不能被100整除,或者能被400整除的年份都是闰年

for num in range(0,10):
    year = int(input("Please input your year : "))
    if (year % 4) == 0 and (year % 100) != 0 or (year % 400) == 0:      
        print("{0}年是闰年".format(year))
    else:
        print("{0}年不是闰年".format(year))
Please input your year : 500
500不是闰年
Please input your year : 100
100不是闰年
Please input your year : 400
400是闰年
Please input your year : 22
22不是闰年
Please input your year : 2000
2000是闰年



猜你喜欢

转载自blog.csdn.net/weixin_42652708/article/details/80984127
今日推荐