输入某年某月某日,判断这一天是这一年的第几天?

简介: from pip._vendor.distlib.compat import raw_inputyear = int(raw_input("please enter the year :"))month = int(raw_input("please enter the m...
from pip._vendor.distlib.compat import raw_input

year = int(raw_input("please enter the year :"))
month = int(raw_input("please enter the month:"))
day = int(raw_input(" please enter the day:"))

#每月第一天,默认2月为28天
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 = False

if (year % 400 == 0) or ((year % 4 == 0) and (year % 100 != 0)):
    leap = True
    if leap is True and month == 2:
        sum += 1

print("您输入的日期为"+str(year)+"年的"+str(sum)+"天!")
目录
相关文章
|
14天前
输入年份判断是否为闰年
输入年份判断是否为闰年
12 0
输入年份判断是否为闰年
|
14天前
输入年月日查询是这一年的第几天(详解)
输入年月日查询是这一年的第几天(详解)
12 1
|
28天前
|
索引
每日一题吼吼吼(打印从1到最大n位数,计算是第几天)
每日一题吼吼吼(打印从1到最大n位数,计算是第几天)
11 0
|
3月前
判断星期几
【1月更文挑战第20天】判断星期几。
26 0
|
3月前
|
Python
判断用户输入的年份是否为闰年:
判断用户输入的年份是否为闰年:
|
10月前
|
Python
输入年月日判断是本年的第多少天
输入年月日判断是本年的第多少天
121 0
|
11月前
判断某年某月的天数
输入年份和月份,返回该月份的天数
|
12月前
每日一题——输入一个日期,输出它是该年的第几天
哈喽大家好,我是保护小周ღ,本期为大家带来的是编程实现输入某年某月某日,输出它是这一年的第几天,一起来看看把~
181 0
闰年判断,输出当前是这一年的第几天
题目描述: 定义一个结构体变量(包括年、月、日)。计算该日在本年中是第几天,注意闰年问题。
89 0
【C#每日一题】输入任意一个日期显示出它是当年的第几天?星期几?并打印出当月的日历
作业1:输入任意一个日期显示出它是当年的第几天?星期几?并打印出当月的日历 运行结果: 上代码: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { .
123 0
【C#每日一题】输入任意一个日期显示出它是当年的第几天?星期几?并打印出当月的日历