写代码:输入一年份,判断该年份是否是闰年并输出结果。

# 输入一年份,判断该年份是否是闰年并输出结果。
# 注: 凡符合下面两个条件之一的年份是闰年。
# 1. 能被4整除但不能被100整除。
# 2. 能被400整除。

year = int(input("please enter the year: "))

if year % 4 == 0 and year % 100 > 0:
print("The %s is leap year" % year)
elif year % 400 == 0:
print("The %s is leap year" % year)
else:
print("The %s is NOT leap year" % year)

猜你喜欢

转载自www.cnblogs.com/demilyc/p/9978295.html