def encode(msg,key) :
result=""
for i in range(0,len(msg)) :
c=msg[i]
if "a"<=c<="z":
result=chr((ord(c)+key-ord("a"))%26+ord("a"))+result
elif "0"<=c<="9" :
result=result+chr((ord(c)-key-ord("0"))%10+ord("0"))
return result
msg=input("请输入明文:")
key=int(input("请输入密钥:"))
re=encode(msg,key)
print(re)
程序运行后,输入 msg 的值为“1a2b3c” ,key=2,输出的结果是( )
A.edc901 | B.edc345 | C.9c0d1e | D.3c4d5e |

同类型试题

y = sin x, x∈R, y∈[–1,1],周期为2π,函数图像以 x = (π/2) + kπ 为对称轴
y = arcsin x, x∈[–1,1], y∈[–π/2,π/2]
sin x = 0 ←→ arcsin x = 0
sin x = 1/2 ←→ arcsin x = π/6
sin x = √2/2 ←→ arcsin x = π/4
sin x = 1 ←→ arcsin x = π/2


y = sin x, x∈R, y∈[–1,1],周期为2π,函数图像以 x = (π/2) + kπ 为对称轴
y = arcsin x, x∈[–1,1], y∈[–π/2,π/2]
sin x = 0 ←→ arcsin x = 0
sin x = 1/2 ←→ arcsin x = π/6
sin x = √2/2 ←→ arcsin x = π/4
sin x = 1 ←→ arcsin x = π/2

