Python 输出指定范围的闰年

iFulling 2021-11-25 14:04:20
Python 指定 输出 范围 闰年

任务:输出指定范围之间的闰年,每行5个

第一步:判断是否是闰年

""" 功能: 判断平闰年 作者: Fulling 时间: 2021年11月5日 """
year = int(input('输入年份: '))
# 普通闰年:公历年份是4的倍数,且不是100的倍数的为闰年
# 世纪闰年:公历年份是整百数的,必须是400的倍数才是闰年
if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:
print('%d年是闰年' % year)
else:
print('%d年是平年' % year)

输出结果:

输入年份: 1900
1900年是平年
输入年份: 2000
2000年是闰年

第二步:指定一个范围

""" 功能: 输出指定范围的闰年 作者: Fulling 时间: 2021年11月5日 """
# 输入部分
start = int(input('输入开始年份:'))
end = int(input('输入结束年份:'))
# 处理和输出部分
count = 0
print('%d 年到 %d 年的闰年有:' % (start, end))
for i in range(start, end + 1):
if i % 4 == 0 and i % 100 != 0 or i % 400 == 0:
print('%d年' % i, end=" ")
# 每五个一排
count += 1
if count % 5 == 0:
print()

输出结果:

输入开始年份:1900
输入结束年份:2000
1900 年到 2000 年的闰年有:
1904190819121916192019241928193219361940194419481952195619601964196819721976198019841988199219962000
版权声明
本文为[iFulling]所创,转载请带上原文链接,感谢
https://blog.csdn.net/realoser/article/details/121532902

  1. Python爬虫编程思想(85):在Python中使用非关系型数据库
  2. Volume de réglage audio Python (avec Code) | outils Python
  3. Python crawler programming idea (59): get attribute value and text with beautiful soup CSS selector
  4. Python crawler programming idea (57): basic usage of CSS selector in beautiful soup
  5. Python crawler programming idea (55): find of beautiful soup method selector_ All method
  6. Python crawler programming idea (54): use beautiful soup to select sibling nodes
  7. Python crawler programming idea (53): use beautiful soup to select the parent node
  8. Django3.0 solves the problem of error reporting in reverse parsing
  9. Precautions for Python crawler
  10. Python 3 crawler series (1) -- climbing blind date websites
  11. Python到底是什么?为什么要学Python?
  12. #yyds干货盘点#Pandas数据清洗实用指南
  13. Python打包exe文件无法运行
  14. Two common ways to save files in Python
  15. #yyds幹貨盤點#Pandas數據清洗實用指南
  16. Yyds Dry Inventory pandas Data Cleaning Practical Guide
  17. PYTHON用LSTM长短期记忆神经网络的参数优化方法预测时间序列洗发水销售数据
  18. Python集成学习:自己编写构建AdaBoost分类模型可视化决策边界及sklearn包调用比较
  19. Python 3 makes a search software
  20. Python 3 simulated microblog login
  21. Using Python 3 to make practical software for drawing modification
  22. About HTML (acceptable to Python)
  23. Python集成學習:自己編寫構建AdaBoost分類模型可視化决策邊界及sklearn包調用比較
  24. PYTHON用LSTM長短期記憶神經網絡的參數優化方法預測時間序列洗發水銷售數據
  25. Python Integrated Learning: Writing and Constructing adaboost Classification Model Visualized decision Boundary and sklearn package Calling Comparison
  26. Python prédit les données de vente de shampooing de séries chronologiques en utilisant la méthode d'optimisation des paramètres du réseau neuronal de mémoire à court et à long terme lstm
  27. [zero basics of Python to introduction] a prerequisite for Python preparatory knowledge -- basic coding specification of Python
  28. OpenCV对比度亮度变换竟能用来去水印(附Python/C++源码)
  29. [zero basics of Python to getting started] a prerequisite for Python preparatory knowledge -- installing the visualization tool pycharm
  30. The test modifies main.py in micro python
  31. Microphoton experimental circuit board based on mm32f3273 - does not work normally
  32. Run micropathon on mm32f3273 to test performance
  33. Design mm32f3277 micro Python experimental board with SD card
  34. Mm32f3277 corresponding interface files during microphoton migration
  35. Mm32f3277 microphoton experimental board design and software testing
  36. Making and testing mm32f3277 microphoton minimum circuit board
  37. Download mm32-link program automatically with Python simulated mouse
  38. A curriculum of "artificial intelligence Python machine learning and deep learning"
  39. Test the basic functions of mm32 microphoton test circuit board
  40. Test the basic functions of the mm32f3277 micro Python development board flying one by one
  41. Debugging mm32f3277 from zhufei, transplanted with micro Python development board
  42. Recognizing numbers using OpenCV and python
  43. 真的太香了,Python速查表终于出中文版了
  44. Django REST Framework(DRF)教程:快速入门
  45. python django objects filter过滤查询:startswith year
  46. Data encapsulation of Excel test cases in Python
  47. 学员管理系统python
  48. 肝了一夜,8000字概括精髓,pandas必知必会50例!
  49. Python竟然可以画漫画!漫画版的故宫导游图,来袭!
  50. Networkx graph theory Dijkstra algorithm shortest path implementation, Python
  51. Draw a HelloWorld with Python turtle Library
  52. 运行django的服务器内存使用偶尔跳高一点,重启服务马上下来,是内存泄露吧
  53. Basic usage of Python tqdm module in machine learning training
  54. Python -- basic usage method and basic template of argparse module
  55. python-sockertserver并发编程思想
  56. Programmation simultanée du serveur de sockets Python
  57. Vue+Django 旅游网项目 首页前端实现
  58. Classic usage of pandas: iloc and LOC of data filtering
  59. Calendar module of Python time series
  60. A super easy to use Python standard library. It's great to operate directories and files