第1关 日期格式转换
x=input("输入日期")
#开始
if len(x)==7:
yf=int(x[3:5])
nf=int(x[0:2])
rq=int(x[6])
elif len(x)==8:
yf = int(x[5:6])
nf = int(x[0:4])
rq = int(x[7])
elif len(x)==9:
yf = int(x[5:6])
nf = int(x[0:4])
rq = int(x[7:9])
elif len(x)==10:
yf = int(x[5:7])
nf = int(x[0:4])
rq = int(x[8:10])
yf1 = (
"January", "February", "March", "April ", "May", "June", "July", "August", "September", "October", "November",
"December")
yf2=yf1[yf-1]
y='{} {},{}'.format(yf2,rq,nf)
z='{} {},{}'.format(rq,yf2,nf)
#结束
print("美式格式"+y)
print("英式格式"+z)
第2关 计算购买饮品金额
cp=(("悠哉悠哉",18),("人间烟火",17),("蔓越阑珊",17),("抹茶葡提",16),("幽兰拿铁",16),(" 翠翠 ",13),("浮生半日",15),("筝筝纸鸢",16),("声声乌龙",15),("风栖绿桂",12),("素颜锡兰",13),("烟火易冷",15))
#代码开始
for i in range(1,13):
pl=cp[i-1][0]
jg=cp[i-1][1]
# k.append('{}:{}'.format(pl,jg))
print("%2s%s%s"%(i,pl,jg))
# print(k)
price=0
while True:
n=int(input("请选择饮品"))
jg = cp[n - 1][1]
if n!=0:
sl=int(input("请输入数量"))
price+=sl*jg
else:
break
print("应付{}元".format(price))
#代码结束
x=input("")
#代码开始
l=['1','2','3','4','5','6','7','8','9','0']
jh=set(x)
jh.difference_update(l)
if len(jh)-2==26:
print('True')
else:
print('False')
#代码结束
第4关 集合的运算
#代码开始
hd1=set()
hd2=set()
gh=input("")
lb=gh.split(',')
for x in lb:
hd1.add(eval(x))
gh=input("")
lb=gh.split(',')
for x in lb:
hd2.add(eval(x))
hd3=hd1&hd2
hd4=hd1-hd3
hd5=hd2-hd3
print("两项活动都参加",hd3)
print("只参加活动1",hd4)
print("只参加活动2",hd5)
#代码结束