如何使用Python检查Le年?
每四年years年。对于正常年份,如果可以将其整除为四,则称为leap年,而对于世纪年份,则应将其整除为400。以下Python程序显示该年份是否为leap年
yr=int(input('enter year'))if yr%100==0: #century year if yr%400==0: print ('{} is leap year'.format(yr)) else: print ('{} is not leap year'.format(yr))else: if yr%4==0: print ('{} is leap year'.format(yr))else: print ('{} is not leap year'.format(yr))
样本输出:
enter year20122012 is leap yearenter year20182018 is not leap year2000 is leap yearenter year19001900 is not leap year
以上是 如何使用Python检查Le年? 的全部内容, 来源链接: utcz.com/z/331437.html