python二级练习(4)

栏目: Python · 发布时间: 8年前

内容简介: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

http://edu.csdn.net/course/detail/6149

Python游戏开发入门


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Learning PHP 5

Learning PHP 5

David Sklar / O'Reilly / July, 2004 / $29.95

Learning PHP 5 is the ideal tutorial for graphic designers, bloggers, and other web crafters who want a thorough but non-intimidating way to understand the code that makes web sites dynamic. The book ......一起来看看 《Learning PHP 5》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试