#!/usr/bin/python
# -*- coding:utf-8 -*-
count=0
sum=0
result=0
sfz = raw_input("请输入身份证前17位数:")
if len(sfz) == 17:
for x in sfz:
count +=1
if count == 1:
sum=sum+int(x)*7
elif count == 2:
sum=sum+int(x)*9
elif count == 3:
sum=sum+int(x)*10
elif count == 4:
sum=sum+int(x)*5
elif count == 5:
sum=sum+int(x)*8
elif count == 6:
sum=sum+int(x)*4
elif count == 7:
sum=sum+int(x)*2
elif count == 8:
sum=sum+int(x)*1
elif count == 9:
sum=sum+int(x)*6
elif count == 10:
sum=sum+int(x)*3
elif count == 11:
sum=sum+int(x)*7
elif count == 12:
sum=sum+int(x)*9
elif count == 13:
sum=sum+int(x)*10
elif count == 14:
sum=sum+int(x)*5
elif count == 15:
sum=sum+int(x)*8
elif count == 16:
sum=sum+int(x)*4
elif count == 17:
sum=sum+int(x)*2
result=sum%11
if result == 0:
result=1
elif result == 1:
result=0
elif result == 2:
result="X"
elif result == 3:
result=9
elif result == 4:
result=8
elif result == 5:
result=7
elif result == 6:
result=6
elif result == 7:
result=5
elif result == 8:
result=4
elif result == 9:
result=3
elif result == 10:
result=2
if result == "X":
print("该身份证的第18位数位:"+result)
else:
print("该身份证的第18位数位:"+str(result))
else:
print("输入有误,再见!")
# -*- coding:utf-8 -*-
count=0
sum=0
result=0
sfz = raw_input("请输入身份证前17位数:")
if len(sfz) == 17:
for x in sfz:
count +=1
if count == 1:
sum=sum+int(x)*7
elif count == 2:
sum=sum+int(x)*9
elif count == 3:
sum=sum+int(x)*10
elif count == 4:
sum=sum+int(x)*5
elif count == 5:
sum=sum+int(x)*8
elif count == 6:
sum=sum+int(x)*4
elif count == 7:
sum=sum+int(x)*2
elif count == 8:
sum=sum+int(x)*1
elif count == 9:
sum=sum+int(x)*6
elif count == 10:
sum=sum+int(x)*3
elif count == 11:
sum=sum+int(x)*7
elif count == 12:
sum=sum+int(x)*9
elif count == 13:
sum=sum+int(x)*10
elif count == 14:
sum=sum+int(x)*5
elif count == 15:
sum=sum+int(x)*8
elif count == 16:
sum=sum+int(x)*4
elif count == 17:
sum=sum+int(x)*2
result=sum%11
if result == 0:
result=1
elif result == 1:
result=0
elif result == 2:
result="X"
elif result == 3:
result=9
elif result == 4:
result=8
elif result == 5:
result=7
elif result == 6:
result=6
elif result == 7:
result=5
elif result == 8:
result=4
elif result == 9:
result=3
elif result == 10:
result=2
if result == "X":
print("该身份证的第18位数位:"+result)
else:
print("该身份证的第18位数位:"+str(result))
else:
print("输入有误,再见!")