第3章-1 3-1.大于身高的平均值
list=input().split(" ")
#print(list[0])
sum=0.0
for i in list:
sum+=int(i)
sum/=len(list)
flag=False;
for i in list:
if int(i)>sum:
print("{:d} ".format(int(i)),end="")
第3章-2 查验身份证
num=int(input())
a=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]
z=['0','1',2,3,4,5,6,7,8,9,10]
m=['1','0','X','9','8','7','6','5','4','3','2']
flag=False
#print(int(a[1]))
while num>0:
num-=1
s=input()
sum=0
t=False
for i in range(17):
if s[i]>='0' and s[i]<='9':
sum+=int(s[i])*int(a[i])
else:
flag=True
t=True
break
# print(m[sum%11])
#print(s[17])
if t:
#print("======")
print(s)
#if m[sum%11]!=s[17]:
# print("hahahahah")
if (m[sum%11])!=(s[17]) and not t:
print(s)
flag=True
if flag==False:
print("All passed")
第3章-3 输出字母在字符串中位置索引
s=input()
a,b=input().split(" ")
# print(a)
# print(b)
# print(s[-1])
for i in range(len(s)):
# print(len(s)-i-1)
if s[len(s)-i-1]==a:
print("{:d} ".format(-i+len(s)-1),end="")
print(a)
if s[len(s)-i-1]==b:
print("{:d} ".format(-i+len(s)-1),end="")
print(b)
第3章-4 查找指定字符
a=input()
b=input()
flag=False
for i in range(len(b)):
# print(b[len(b)-i-1])
# print(b)
if b[len(b)-i-1]==a:
print("index = {:d}".format(len(b)-i-1))
flag=True
break
if flag==False:
print("Not Found")
第3章-5 字符转换
s=input()
ans=0
for i in range(len(s)):
if s[i]>='0' and s[i]<='9':
ans=ans*10+int(s[i])
print(ans)