判断给到的年份是否为闰年

Posted 道高一尺

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了判断给到的年份是否为闰年相关的知识,希望对你有一定的参考价值。

#写一个程序,判断给到的年份是否为闰年
temp=input(‘请输入一个年份:‘)
while temp.isdigit()==False:
    temp=input(‘该吃药了吧,重新输入:‘)
year=int(temp)
if ((year%4==0) and (year%100!=0)) or (year%400==0):
    print(temp+‘年是闰年‘)
else:
    print(temp+‘年不是闰年‘)  

以上是关于判断给到的年份是否为闰年的主要内容,如果未能解决你的问题,请参考以下文章