发布网友 发布时间:2022-04-23 13:32
共1个回答
热心网友 时间:2022-04-07 13:32
mons = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
def get_days(mon, day):
if mon == 1:
return mons[0], day
else:
count = sum(mons[:mon-1])
count = count + day
return mons[mon - 1], count
mon = int(input("请输入月份:"))
day = int(input("请输入号数:"))
result = get_days(mon, day)
print("{}月有{}天。".format(mon, result[0]))
print("{}月{}号是该年的第{}天".format(mon, day, result[1]))