猫史档案馆


【Python作品分享】5行代码算平闰

用户:PTG_Python程序员PTG_Python程序员查看:2 回复:2 评论:2 创建时间:2020-07-08T11:56:42


【作品展示】

center_image

 

【作品介绍】

他知道哪一年是闰年,哪一年是平年。

 

【作品源代码】

y = int(input('年:'))
if (y % 4 == 0 and y % 100 != 0 or y % 400 == 0):
    print('闰')
else:
    print('平')

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
NaSNaS

容我直言啊……

这个作品是很棒 可是只要看是不是4(40)(400)的倍数就行了啊......

点赞2


评论


蒟蒻OIer1048576蒟蒻OIer1048576

a = int(input('年?'))
print('是' if a % 4 == 0 and a % 100 != 0 or a % 400 == 0 else '不是')

点赞1


评论