1 Star 0 Fork 2

Asheng/python100

forked from Yonja/python100 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
python4.py 859 Bytes
一键复制 编辑 原始数据 按行查看 历史
zhangweizhi 提交于 2016-06-04 15:16 +08:00 . the 100 theme
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
题目:输入某年某月某日,判断这一天是这一年的第几天?
程序分析:以3月5日为例,应该先把前两个月的加起来,
然后再加上5天即本年的第几天,
特殊情况,闰年的2月是29天,如果年份是闰年,并且闰年的
月份在3月以后,则需要多加1天。
每四年一次闰年。
1,3,5,7,8,10,12月是31天,2月是28天,其他的是30天。
"""
year = int (raw_input('year:\n'))
month = int (raw_input('month:\n'))
day = int (raw_input('day:\n'))
months = [0,31,59,90,120,151,181,212,243,273,304,334]
if 0<month<=12:
sum = months[month - 1]
else:
print 'data error'
sum += day
leap = 0
if (year % 400 == 0) or (year % 4 == 0) and (year % 100 != 0):
leap = 1
if (leap == 1) and (month >2):
sum += 1
print 'It is the %dth day.'% sum
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/Asheng008/python100.git
git@gitee.com:Asheng008/python100.git
Asheng008
python100
python100
master

搜索帮助