内容简介:python二级练习(4)
4. 用 Python 编写程序,输入一年份,判断该年份是否是闰年并输出结果。
注:凡符合下面两个条件之一的年份是闰年。 (1) 能被4整除但不能被100整除。 (2) 能被400整除。
#python 3.6 #蔡军生 #http://blog.csdn.net/caimouse/article/details/51749579 # year = int(input('请输入年份:')) if year % 400 == 0: print(year, ' 是闰年。') elif year % 4 == 0 and year % 100 != 0: print(year, ' 是闰年。') else: print(year, ' 不是闰年。')
结果输出如下:
========== RESTART: D:/work/example/py_ex_004.py ==========
请输入年份:2018
2018 不是闰年。
>>>
========== RESTART: D:/work/example/py_ex_004.py ==========
请输入年份:2100
2100 不是闰年。
>>>
========== RESTART: D:/work/example/py_ex_004.py ==========
请输入年份:2016
2016 是闰年。
>>>
========== RESTART: D:/work/example/py_ex_004.py ==========
请输入年份:2000
2000 是闰年。
>>>
========== RESTART: D:/work/example/py_ex_004.py ==========
请输入年份:2200
2200 不是闰年。
>>>
深入浅出Matplotlib
https://edu.csdn.net/course/detail/6859
深入浅出Numpy
Python游戏开发入门
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- [Vue 2.x Todo 教程练习参考答案] 标为完成练习参考答案
- [Vue 2.x Todo 教程练习参考答案] 添加todo练习参考答案
- [Vue 2.x Todo 教程练习参考答案] 入门仪式_Hello_Vue练习参考答案
- python二级练习(6)
- python二级练习(7)
- python二级练习(8)
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Hacking Growth
Sean Ellis、Morgan Brown / Crown Business / 2017-4-25 / USD 29.00
The definitive playbook by the pioneers of Growth Hacking, one of the hottest business methodologies in Silicon Valley and beyond. It seems hard to believe today, but there was a time when Airbnb w......一起来看看 《Hacking Growth》 这本书的介绍吧!