s1="192637"
s2="playground"
s3=""
for i in s1:
s3 = s2[int(i)] + s3
print(s3)
执行该程序段后,输出的结果是( )
a=[1,3,5,7,9]
b=[2,4,6,8,10]
list=[]
for i in range(-1,-5,-1):
s=a[i]+b[i]
list.append(s) #append方法用于在列表末尾添加新元素
print(list)
执行程序后,输出的结果是( )
m=int(input())
s=""
flag = True
while m > 0:
r = m % 10
m = m // 10
if flag and r % 2 != 0:
s = str(r) + s
flag = not flag
print(flag, s)
若输入的值为“5201314”,执行该程序段后,输出的结果是( )
#生成6个随机整数,存入列表元素a[0]到a[5]中,代码略
b=[0]*6
for i in range(1,6):
for j in range(i):
if a[i]>a[j]:
b[i] += 1
print(sum(b))
执行该程序段后,输出的结果是6,则a[0]到a[5]各元素值可能的是( )
请在划线处填入合适的代码
f=open("支出.txt","r")
mx=f.read()
print(mx)
t="";s=0
for i in mx:
if :
t=t+i
flag=True
elif flag:
s=s+int(t)
t=""
flag=False
if flag:
print("一共支出:",str(s),"元")
请在划线处填入合适的代码。
s=input("请输入波群(m)")
a=[]
s=s+","
for j in range(len(s)):
if s[j] == ",":
t = float(s[i:j])
a.append(t) #append方法用于在列表末尾添加新元素
a.sort(reverse = True) #将a列表中的元素从大到小排列
sumbg=0
for k in range(len(a)//3):
sumbg = sumbg + a[k]
print("有效波高(m):",aver)
1)若是大写字母,则进行字母替换:英文26个字母按键盘QWERT的顺序排列,从第一行到第三行连接起来再与字母表顺序进行替换,如Q用A来替换,Y用F替换,如下所示:
2)将经过字母替换后的明文每个字符的8位二进制ASCII码(不足8位的左端补0,补足8位)分成两段(左4位一段,右4位为另一段),如字符“A”的二进制ASCII值为01000001,分段后为0100,0001;
3)将高位段(左边4位)转化为十六进制数(如0100转化为4);
4)对低位段(右边4位)执行0→1,1→0后转化为十六进制数(如0001→1110→14→E);
5)依次连接两位十六进制数,得到该字符的密文,如“Q”的密文为“4E”;
6)将每个字符的密文按照明文的顺序依次连接。
程序运行结果如下图所示:
实现上述功能的Python程序如下,请回答下列问题:
def dtb(num): #十进制转8位二进制,高低4位分别处理
i=0;result=""
while i<8:
if i<4:
y=1-num % 2
else:
y=num % 2
num=num//2
result=str(y)+result
i+=1
return result
mw=input("请输入待加密的字符:")
jm=""
mm={"Q":"A","W":"B","E":"C","R":"D","T":"E","Y":"F","U":"G","I":"H","O":"I","P":"J","A":"K","S":"L","D":"M","F":"N","G":"O","H":"P","J":"Q","K":"R","L":"S","Z":"T","X":"U","C":"V","V":"W","B":"X","N":"Y","M":"Z"}
for i in range(len(mw)):
if "A"<=mw[i]<="Z":
else:
jm+=mw[i]
jm1=""
for i in range(len(jm)):
zf="0123456789ABCDEF";result1="";sum=0
for i in :
sum=int(jm1[i])*8+int(jm1[i+1])*4+int(jm1[i+2])*2+int(jm1[i+3])
result1+=zf[sum]
sum=0
print("密文为:",result1)
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
from random import random
s=input("依次输入左上角和右下角的坐标值(以‘,’分隔,以‘,’结尾):")
w=[];h=[];k=0;t=0
for i in s:
if i==",":
if k%2==0:
w.append(t) #append方法用于在列表末尾添加新元素
else:
h.append(t)
t=0;k=k+1
else:
print(w,h)
im = #打开图像y.jpg
pix=im.load()
for i in range():
j= h[0]
while j<=h[1]:
R,G,B=pix[i,j]
pix[i,j]=(int(random()*0.8*R),int(random()*0.8*G),int(random()*0.8*B))
j+=1
plt.figure("y1") #指定当前绘图对象
plt.imshow(im) #显示图像
plt.axis("off") #关闭图像坐标
plt.show() #弹出包含了图片的窗口