栏目分类:
子分类:
返回
终身学习网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
终身学习网 > IT > 软件开发 > 后端开发 > Python

python刷题实例|题目:输入某年某月某日,判断这一天是这一年的第几天

Python 更新时间:发布时间: 百科书网 趣学号
year = int(input("the year is:"))
month = int(input("the month is:"))
day = int(input("the day is:"))
total_day = 0
# Determine if it is a leap year
if year % 400 ==0:
    t = 1
    print("%d is a leap year"%year)
elif year%100!=0 and year%4==0:
    print("%d is a leap year"%year)
    t = 1
else:
    print("%d is't a leap year"%year)
    t = 0

# Determine the month
if t == 1:
    list_month = [0,31,29,31,30,31,30,31,31,30,31,30,31]
else:
    list_month = [0,31,28,31,30,31,30,31,31,30,31,30,31]

for i in range(0,month):
    total_day += list_month[i]
print("It's the %d day of %d"%(total_day+day,year))

转载请注明:文章转载自 www.051e.com
本文地址:http://www.051e.com/it/1033529.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 ©2023-2025 051e.com

ICP备案号:京ICP备12030808号