上面两个链接可直达。
032:石头剪刀布
def whowin(x,y):
if x==0 and y==2 or x==2 and y==5 or x==5 and y==0:
return 1
elif not x==y :
return 0
a=input().split()
A,B,C=int(a[0]),int(a[1]),int(a[2])
b=input().split()
c=input().split()
xb,xc=0,0
for i in range(A):
if whowin(int(b[i%B]),int(c[i%C]))==1:
xb+=1
elif whowin(int(b[i%B]),int(c[i%C]))==0:
xc+=1
if xb==xc:
print("draw")
elif xb>xc:
print("A")
else :
print("B")
033:统计数字字符个数
a=input()
s=0
for i in range(10):
s+=a.count(chr(ord('0')+i))
print(s)
034:大小写字母互换
a = input()
result = ""
for char in a:
if char.isupper():
result += char.lower()
elif char.islower():
result += char.upper()
else:
result +=char
print(result)
035:过滤多余的空格
a = input()
result=""
flag=1
for char in a:
if char ==" " :
if flag :
flag=0
result+=" "
else:
result+=char
flag=1
print(result)
036:找第一个只出现一次的字符
a = input()
flag=1
for char in a:
if a.find(char)==a.rfind(char):
print(char)
flag=0
break
if flag:
print("no")
037:判断字符串是否为回文
a = input()
if a==a[::-1]:
print("yes")
else :
print("no")
038:字符串最大跨距
a = input().split(',')
if a[0].find(a[1])==-1 or a[0].find(a[2])==-1 :
print("-1")
else:
if a[0].rfind(a[2])-a[0].find(a[1])-len(a[1])<0:
print("-1")
else:
print(a[0].rfind(a[2])-a[0].find(a[1])-len(a[1]))
039:找出全部子串位置
a=int(input())
for i in range(a):
b=input().split()
if b[0].find(b[1])==-1:
print("no",end="")
else:
f=b[0].find(b[1])
while f>=0:
print("%d " % f,end="")
f=b[0].find(b[1],f+len(b[1]))
print()
040:万年历
monthdays=[-1,31,28,31,30,31,30,31,31,30,31,30,31]
week=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
num=int(input())
for i in range(num):
# print(i)
s=input().split()
year=int(s[0])
month=int(s[1])
day=int(s[2])
days=0
run=int(year%4==0 and year%100!=0 or year%400==0)
if month == 2 and (day < 1 or day > 28 + run) or (month in [1, 3, 5, 7, 8, 10, 12]) and (day < 1 or day > 31) \
or (month in [4, 6, 9, 11]) and (day < 1 or day > 30) or month > 12 or month < 1:
print("Illegal")
else:
days = year * 365 % 7 + (year // 4 + year // 400 - year // 100) % 7
for i in range(1, month):
days += monthdays[i]
if month < 3:
days -= run
days += day - 1
t = days % 7
print(week[t])