安全问答

安全问答是一个知识全球问答,包含丰富的问答知识

首页 常规 游戏 娱乐 科技 程序员

用python判断输入的年份是闰年还是平年能被400整除或能被4整除且不能被100整除的年份是闰年否则平年year = intinput请输入年份:if year 4 == 0 and year 100 == 0 and year 400 == 0 printyear是闰年else printyear 是平年

  • 日期: 2025-12-07
  • 标签: 财经

修正判断条件

year = int(input("请输入年份:")) if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0: print(year,"是闰年") else: print(year, "是平年")

用python判断输入的年份是闰年还是平年能被400整除或能被4整除且不能被100整除的年份是闰年否则平年year = intinput请输入年份:if year 4 == 0 and year 100 == 0 and year 400 == 0 printyear是闰年else printyear 是平年

原文地址: https://www.cveoy.top/t/topic/bp5U 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录

  • 上一篇: 中国哪个美院最大回答+拓展
  • 下一篇: java中的使用updateById对数据库进行修改数据会覆盖原有的数据吗?

© 2019 • 2025 - 安全问答 站长邮箱:wxgpt@qq.com    ICP备案/许可证号:豫ICP备2024104334号-2