#程序填空。将程序中【?】部分(包括中括号和问号)换成正确答案,其余地方不动。 ''' 题目:输入年月日,输出这是这一年的第几天; ''' #**********SPACE********** year=【1】( input("请输入年份:")) month= input("请输入月份:") day=int( input('请输入日期:')) dic={"1":31,"2":28,"3":31,"4":30,"5":31,"6":30,"7":31, "8":31,"9":30,"10":31,"11":30,"12":31} #**********SPACE********** days=【2】 if ((year%4==0) and (year%100!=0)) or (year%400==0): dic["2"]=29 if int(month)>1: for obj in dic: if month==obj: for i in range(1,int(obj)): days+=dic[str(i)] days+=day else: days=day print('{}年{}月{}日是该年的第{}天'. format(year,month,day,days))
时间: 2023-07-01 07:13:32 浏览: 172
```python
''' 题目:输入年月日,输出这是这一年的第几天; '''
year=int(input("请输入年份:"))
month= int(input("请输入月份:"))
day=int(input('请输入日期:'))
dic={"1":31,"2":28,"3":31,"4":30,"5":31,"6":30,"7":31, "8":31,"9":30,"10":31,"11":30,"12":31}
days=day
if ((year%4==0) and (year%100!=0)) or (year%400==0):
dic["2"]=29
if int(month)>1:
for obj in dic:
if int(month)==int(obj):
for i in range(1,int(obj)):
days+=dic[str(i)]
days+=day
else:
days=day
print('{}年{}月{}日是该年的第{}天'. format(year,month,day,days))
```
修改了输入年份的数据类型为int,并修改了月份的数据类型。
阅读全文