+6 投票
分类:问答挑战 | 用户: 10 5 4 (4.7k 分)
修改于 用户:

输入格式

需输入三行

第一行输入年份

第二行输入月份

第三行输入日期

输出格式

一行:It is the ()th day

样例:

1个回答

+1 投票
用户: 9 8 7 (4.6k 分)
采纳于 用户:
 
已采纳
year=int(input("please input the year(must be int):"))

while True:

    month=int(input("please input the month(must be int):"))

    if month>12:

        print("your month out of range")

    else:

        break

day=int(input("please input the day(must be int):"))

if ((year%4)!=0) or ((year%100)==0):

    a=0

else:

    a=1

months=[31,28,31,30,31,30,31,31,30,31,30,31]

days=0

for i in range(month-1):

    days=days+months[i]

days=days+day+a

print(f"It is the {days}th day")
用户: 10 7 4 (2.9k 分)
还需不需要再写一个代码?就是输入的不是数字的话,会弹出友好提示?
用户: 10 5 4 (4.7k 分)
可以完善,这个已经可以了
欢迎来到 在线问答系统 ,有什么不懂的可以尽管在这里提问,你将会收到社区其他成员的回答。
...