import numpy as np
weight = np.array([7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2])
lookup = dict(zip(list(range(11)),[1,0,'X',9,8,7,6,5,4,3,2]))
n = int(input())
li = []
for i in range(n):
li.append(input())
flag = 1
for each in li:
l = list(each)
last_str = l.pop(-1)
l_str = ''.join(l)
if not l_str.isdigit():
print(each)
flag = 0
else:
l_arr = np.array(list(map(int,l)))
s = sum(weight * l_arr)
z = s % 11
if str(lookup[z]) != last_str:
print(each)
flag = 0
if flag == 1:
print('All passed')
浙大版《Python 程序设计》题目集 第3章-2 查验身份证 (15分)
猜你喜欢
转载自blog.csdn.net/weixin_42229583/article/details/104573185
今日推荐
周排行