程序代码如下:
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
img=np.array(Image.open("chenchen.jpg").convert("L"))
rows,cols=img.shape
for i in range(rows):
for j in range(cols):
if():
img[i,j]=1
else:
img[i,j]=0
plt.imshow(img,cmap="gray")
plt.show()
下列说法正确的是( )
a=[21,3,4,5,9,14,23]
c,m=0,0
for i in range(2,len(a)):
if a[i-2]+a[i-1]==a[i]:
c+=1
if c>m:
m=c
else:
c=0
print(m)
执行程序后,输出结果是( )
s,n=0,8
while True:
s+=n
if s>14:
break
n-=2
print(n,s)
执行程序后,输出结果可能是( )
s=input()
n=len(s);c=1;max=1
for i in range(1,n):
if (1)____:
c=c+1
if c>max:
max=c
else:
划线处可选代码为①c=1 ②c=0 ③s[i]<s[i+1] ④s[i]>s[i-1]
划线处正确的语句依次为( )
s=input()
t=0
mw=''
for i in range(len(s)):
ch=s[i]
if '0'<=ch<='9':
t=t*10+int(ch)
elif ch=='-':
mw+=chr(t%26+ord('A'))
t=0
else:
mw+=ch
print(mw)
执行该程序段输入“29-052-24!”(不包括双引号),则输出的结果是( )
m = int(input("请输入内存容量:"))
s = input("请输入英语句子:")
dic = {}
head = tail = 0
word = ""
for ch in s:
if ch == " " or ch == "," or ch == ".":
if word not in dic or dic[word] < head:
if tail - head == m:
dic[word] = tail
tail + = 1
word = ""
else:
if :
ch = chr(ord(ch) + 32)
word += ch
print("需要去外存查找",,"次词典")