1:
代码:
num = list(input().split(':'))
if(int(num[0])>=12):
if(int(int(num[0])==12)):
num1 =str(int(num[0]))
num2=str(int(num[1]))
num3="PM"
else:
num1 =str(int(num[0])-12)
num2=str(int(num[1]))
num3="PM"
else:
if(int(num[0])==0):
num1="12"
num2=str(int(num[1]))
num3="AM"
else:
num1=str(int(num[0]))
num2=str(int(num[1]))
num3="AM"
print(num1+":"+num2,num3)
2:
代码
st=input()
if(st[-1]=='C'):
num=float(st[:-1])
num1=1.8*num+32
print(str(num1)+"F")
else:
num=float(st[:-1])
num1=(num-32)/1.8
print(str(num1)+"C")
3:
while True:
try:
num =int(input())
if(num>=90 and num<=100 ):
print("A")
elif(num>=80 and num<=89):
print("B")
elif(num>=70 and num<=79):
print("C")
elif(num>=60 and num<=69):
print("D")
elif(num>=0 and num<=59):
print("E")
else:
print("error!")
except:
break
4:
num =int(input())
if(num%4==0):
if(num%400==0):
print("闰年")
else:
if(num%100==0):
print("平年")
else:
print("闰年")
else:
print("平年")
5:
st = input()
if(int(st[-1])%2==0):
print("NO")
else:
print("YES")
6:
import calendar;
st= list(input().split('/'))
if(int(st[1])!=2):
if(int(st[1])!=1 and int(st[1])!=3 and int(st[1])!=5 and int(st[1])!=7 and int(st[1])!=8 and int(st[1])!=10and int(st[1])!=12):
if(int(st[2])<30):
num1=st[0]
num2=st[1]
num3=str(int(st[2])+1)
else:
num1=st[0]
num2=str(int(st[1])+1)
num3="1"
elif(int(st[1])==12):
if(int(st[2])<31):
num1=st[0]
num2=st[1]
num3=str(int(st[2])+1)
else:
num1=str(int(st[0])+1)
num2="1"
num3="1"
else:
if(int(st[2])<31):
num3=str(int(st[2])+1)
num2=st[1]
num1=st[0]
else:
num2=str(int(st[1])+1)
num3="1"
num1=st[0]
8:
num = input()
num = int(num)#字符串转换为整型
if((num-100)<0):
print("输入错误,不是一个三位数")
else:
#取百位
i = int(num/100)
# print(type(i))#浮点型转换为整型
#取十位
j = int(num/10%10)
#取个位
k = int(num%10)
result = i*i*i+j*j*j+k*k*k
if result == num:
print("该数是水仙花数")
else:
print("该数不是水仙花数")
str1 = input()
if(str1[0].lower()=='c' or str1[0].lower()=='f'):
if(str1[0].lower()=='c'):
num=float(str1[1:])
num=round((num*1.8+32),1)
print("F"+str(num))
else:
num=float(str1[1:])
num=round(((num-32)/1.8),1)
print("C"+str(num))
else:
print("输入格式错误")
9:
num =input()
num1=num.split(" ")[0]
num2=num.split(" ")[-1]
if(float(num1)<=50):
num1='{:.2f}'.format(float(num1)*0.53)
print("cost = "+str(num1))
else:
num1='{:.2f}'.format((float(num1)-50)*float(num2)+26.5)
print("cost = "+str(num1))
10:
import calendar;
num1=int(input())
num2=int(input())
if(num2!=2 and num2!=4 and num2!=6 and num2!=9 and num2!=11):
print(str(num1)+"年"+str(num2)+"月是31天")
elif(num2==2):
if(calendar.isleap(num1)):
print(str(num1)+"年"+str(num2)+"月是29天")
else:
print(str(num1)+"年"+str(num2)+"月是28天")
else:
print(str(num1)+"年"+str(num2)+"月是30天")
11:
num=input()
num1=int(num.split(",")[0])
num2=int(num.split(",")[-1])
if(num1>0 and num2>0):
print("第一象限")
elif(num1<0 and num2>0):
print("第二象限")
elif(num1<0 and num2<0):
print("第三象限")
else:
print("第四象限")
12:
num1= int(input())
num2 = 10
if 34 >= num1 >= 20:
num1 -= 8
elif num1 >= 35:
num1 -= 12
if 50 > num1 >= 30:
num2 = 5
elif num1 >= 50:
num2 = 0
print(num1 + num2, end='')
13:
num=int(input())
num1=10**(num-1);
for i in range(num1,num1*10):
one=i//num1
two=i//(num1/10)%10
end_one=i%10
end_two=i//10%10
if(one==two and end_one+end_two==5 and i%3==0 and end_one%2==1):
print(i)
14:
num=list(input().split(" "))
num2=""
for i in num:
num2 = num2+i
num3='{:.2f}'.format(len(num2)/len(num))
print(str(len(num))+","+num3)
15:
num = int(input())
num2=1
num3=0
if(num==1):
print("1")
else:
for i in range(1,num+1):
num2=i*num2
num3=num3+num2
print(num3)
16:
num=list(input())
if(len(num)!=18):
print("错误")
else:
for i in range(0,len(num)-1):
num[i]=int(num[i])
num2=7*num[0]+9*num[1]+10*num[2]+5*num[3]+8*num[4]+4*num[5]+2*num[6]+1*num[7]+6*num[8]+3*num[9]+7*num[10]+9*num[11]+10*num[12]+5*num[13]+8*num[14]+4*num[15]+2*num[16]
Z=num2%11
M={0:1,1:0,2:"X",3:9,4:8,5:7,6:6,7:5,8:4,9:3,10:2}
if(str(M[Z])==num[17]):
print("正确")
else:
print("错误")
17:
num=input().replace(" ","")
num=list(num[1:len(num):2])
for i in range(0,len(num)):
num[i]=int(num[i])
num2=[]
num3=[]
for i in num:
if(i not in num2):
num2.append(i)
else:
num3.append(i)
for i in num3:
print(i,end=' ')