浙江选考信息技术客观题专题汇编之专题七Python基础2一一字符串处理、随机数、解析和枚举的应用、图像模块(PDF版,含答案)

文档属性

名称 浙江选考信息技术客观题专题汇编之专题七Python基础2一一字符串处理、随机数、解析和枚举的应用、图像模块(PDF版,含答案)
格式 zip
文件大小 798.1KB
资源类型 教案
版本资源 浙教版(2019)
科目 信息技术(信息科技)
更新时间 2022-12-27 20:13:42

图片预览

文档简介

Python 2
1. 2022 5 10
1. n 9 9
9 Python
n=2022 ; s=0 ; t =0
while n>0:
if s%9==0:
9
else:
9
s=s+t
n=n//10
t=n %10
A. B. C. D.
2. 2022 5 12
2. Python :
for i in range(1,len(s)):
if t>=0 and s[i]==a[t]:
t=t-1
else:
t=t+1
a[t]=s[i]
, , t
A. ++**+ B. +*+** C. *+**+ D.
*++*+
3. 2022 6 12
3. Python
- 1]]
while t!= - 1:
s=d[t][1]
outs=chr((ord(d[t][0])-97+d[s][0])%26+97)+outs
t=d[s][1]
print(outs)
“a ” ASCII 97
A.yuzb B.bzyu C.kmdd
D.ddmk
1/14
4. 2022 6 8
4. Python
n=0 s=[1,1,2,2,2,3,1,1,3,3]
for i in range(0,len(s)-1):
if s[i]==s[i+1]:
n+=1
else:
n-=1
print(n)
n
A. 0 B. 1 C. -1 D. 2
5. 2022 6 10
5. s 2 3 5 8 , s Python
1 2 3 5
def sum(n):
s=0 ; x=2 ; y=1
for i in range(0, n):
return s
print(sum(n))
x=x+y y=x s=s+x/y y=x-y
A. B. C. D.
6. 2022 6 11
6. (DNA) DNA
4 (A) (G) (T) (C)
A T G C :
import random
DNA=['A','G','T','C']
s=' '
for i in range(20):
print(s)
match={'A':'T','T':'A','G':'C','C':'G'}
t=' '
for i in range(20):
print(' :',t)
A. s=random. choice()+s t= t+match[i]
B. s=s+random. choice(DNA) t= t + match[s[i]]
C. s=s+random. choice() t= t + match[s[i]]
2/14
D. s=random. choice(DNA)+s t= t + match[i]
7. 2022 6 12
7. Python
a = [3,2,1,-8,3,-2,8,6]
s = t = a[0]
for i in range(1,len(a)):
if s > 0:
s += a[i]
else:
s = a[i]
if s > t:
t = s
print(t)
A. 6 B. -10 C. 15 D. 33
8. 2022 6
8. a ( b
8 a 8 b
:
from PIL import Image
import matplotlib. pyplot as plt
img = Image.open .convert
pix = img.load
for row in range img.width :
for col in range img. height :
if pix[row,col] >128:
pix[row,col] = 0
else:
pix[row,col] = 1
plt.imshow
plt.axis
plt.show
A. :“ . jpg” B. 128 50
C. plt. show() D.
3/14
9. 2022 9
9. random b
b
A. random. choice(b) B. random. sample(b,1) C. b[random. randint(0,2)] D.
b[random. random()*3]
10. 2022 10
10. : ;
; Python
idiom(x) x
ws = []
ws. append (head)
……
c = 0
while ( ) and idiom(w):
c += 1
ws. append(w)
print(ws)
: ”,c)
A. len(w) == 4 and w[0] in ws[len(ws) - 1] and w not in ws
B. not (len(w) != 4 or w[-4] not in ws[-1] or w in ws)
C. not (len(w) != 4) and w[o] in ws[-1] and not (w in ws)
D. len(w) != 4 and w[-4] in ws[-1] and w not in ws
11. 2022 6 6
11 python
def encrypt(code,key):
for s in code:
s1= ord('a')+((ord(s)-ord('a'))+key)%26
code_new+=chr(s1)
return code_new
print(encrypt(code,2))
A
B code App , crr
C (int(s)+key)%10
D ord('a')+((ord(s)-ord('a'))-key)%26
12. 2022 7 10
4/14
12. Python
p='Tel-114'
c=' '
for ch in p:
c+=str(9-int(ch))
c+=chr(ord(ch)-
else:
c+=ch
print(c)
A. tEL-885 B. tEL-114 C. TEL-114 D. TEL-885
13. 2022 8 A9 8
13 Python
s =
f = True
for i in range(0,len(s)//2):
if s[i] != s[len(s)-i-1]:
f = False
break
print(f)
“True”
A onion B hello C 278
D 111
14. 2022 8 A9 10
14 Python
m = cnt = 1
for i in range(1,len(s)):
if s[i]>s[i-1]:
cnt += 1
if cnt > m :
m = cnt
else:
cnt = 1
print(m)
A s B s
C s D s
15. 2022 8 A9 12
5/14
15 Python
from random import random
i = 0
a = [0]*6
while i<=5:
a[i] = (int(random()*6+5))*(i%2+1)
for j in range(i):
if a[j] == a[i]:
i = i-1
break
i=i+1
a
A [6, 12, 5, 18, 8, 10] B [7, 18, 10, 10, 6, 12] C [8, 15, 6, 16, 7, 12] D [5,
16, 12, 18, 9, 10]
16. 2022 8 Z20 8
16 Python
;
for i in range(len(s)):
x=chr(((ord(s[i])-95))%26+97) # ASCII 97
x=chr(((ord(s[i])-41))%26+65) # ASCII 65
flag=False
else:
x=s[i];flag=True
k=k+x
print(k)
A ZAyb#dK B yzYZ#Dm C zaYB#Dk D zaYZ#Dm
17. 2022 8 9
17. Nilakantha Pi(
Pi(
n Pi
( )
s=0;n=0;i=0
n
for i in range(2,2*n+1, ):
s=s+
print (s)
pi = 3 + s * 4
print(pi)
A. 1 (-1)**(i//2+1)/(i*(i+1)*(i+2)) B. 2
6/14
(-1)**(i//2+1)/(i*(i+1)*(i+2))
C. 1 (-1)**(i//2)/(i*(i+1)*(i+2)) D. 2 (-1)**(i//2)/(i*(i+1)*(i+2))
18. 2022 8 10
18. “ ” 10
; 1
5 ( )
import random import time import os
10
for i in range(10):
) #
time. sleep(10) # 10
#
n=0 # 0
t2=random. sample( ,5) # 5
for i in t2: # 5
#
if i==
n=n+1 # 1
\n #
\n
A. things[i] things things[ans]
B. things things things[i]
C. things[i] things[i] things[ans]
D. things[ans] things[ans] things[i]
19. 2022 8 12
19.
import random
a=[0]*6
for i in range(6):
a[i]=random. randint(1,5)*2+1
i=0
while i<5:
if a[i]>a[i+1]:
a[i],a[i+1]=a[i+1],a[i]
else:
a[i]+=1
i+=1
print(a)
a ( )
A. [2,5,10,10,10,9] B. [3,8,7,13,3,9] C. [8, 12, 3, 5, 3, 11] D. [6,10,9,7,10,8]
20. 2022 9 9
7/14
20. Python
for i in range ( len ( s ) ) :
c = s [ i ]
if i % 2 == 0:
c = chr ( ( ord ( c ) – –
else:
c = c . upper ( ) # x . upper( ) x
ans += c
print ( ans )
A. PYwHtN B. YrHkN C. PaTIOt D. PYrHkN
21. 2022 9 5
21. Python :
f=[0]* 128
for i in n:
f[ord(i)]+=1
for i in n:
if (f[ord(i)]==1):
print(i,
ace3,
A. abecb3b B. bacea3b C. babcbe3 D. b3ace3d
22. 2022 9 8
22. Python :
t=[1 3 2]
for i in range (1en(s)):
m= t[i % len(t)]
n= ord(s[i]) + m
res = res + chr(n)
print (res)
A. Dkkod B. Ciknb C. DkjoD D. Cijob
23. 2022 10 10
23. Python
k=3
sum,j,c=0,0,0
8/14
flag=False
for ch in s:
c=c*10+int(ch)
j+=1
flag=True
else:
if j==k and flag:
sum+=c
flag=False
j=0;c=0
s sum
A.18 B.101 C. 119 D.321
24. 2022 11 10
24. n
n a
b b[i][0] b[i][1]
Python
p = len(b)
i = 0
while i < p:
for j in range(n):
if b[i][0]==a[j]:
print(b[i][1])
i = i + 1
A.
B. p
C. n
D.
25. 2022 11 12
25.
from random import randint
k = randint(1, 4)
for i in range(k):
j = i + 1
while j < len(s) and s[j] > s[i]:
j += 1
if j < len(s):
s = s[:j] + s[j + 1:]
9/14
else:
s = s[:len(s) - 1]
print(s)
s
26. 2022 11 11
26. the
['t', 'th', 'the', 'h', 'he', 'e']
a=[]
for i in range(len(s)):
for j in range( ):
a.append( )
print(a)
A. i,len(s) s[i:j+1] B. i,len(s)-i+1 s[i:j+i]
C. i,len(s)-i+1 s[i:j+1] D. i,len(s) s[j:j+i]
27. 2022 11 10
27. python
n=int(input())
s=0
i=1
while i*i<=n:
if i==n//i:
s=s+1
elif n%i==0:
s=s+2
i=i+1
print(s)
16
A. 3 B. 4 C. 5 D. 6
28. 2022 11 8
28. python
for i in s:
if i in
ans = ans + i
else:
ans = i + ans
print(ans)
10/14
A. 10 B. 31024 C. 42013 D. 43210
29. 2022 11 11
29. python
from random import randint
a ,b = [10] , [10]
for i in range(5):
a.append(a[-1] + randint(1,10))
for i in range(9):
b.append(b[-1] + randint(1,10))
c = []
while 1 :
if 2 :
c.append(b.pop(0))
elif 3 :
c.append(a.pop(0))
elif 4 :
c.append(a.pop(0))
else:
c.append(b.pop(0))
print(c)
len(a) > 0 and len(b) > 0 len(a)>0 or len(b)>0 len(a)> 0 len(a) == 0
len(b) > 0 len(b) == 0 b[0]A. B. C. D.
30. 2022 11 9+1 9
30. Python
-
for ch in p:
c+=str(9-int(ch))
c+= chr(ord(ch)-
else:
c+=ch
print(c)
A. tEL-678 B. TEL-678 C. TEL-321 D. tEL-321
31. 2022 10
31. 2 3 5 (Ugly Number), 20 “2, 3, 4, 5, 6, 8, 9, 10,
12, 15, 16, 18, 20” x
x = 20;res = [1];a = b = c = 0
while res[-1] < x:
res. append(min(res[a] * 2, res[b] * 3, res[c] * 5))
11/14
print(res[1:])
A. if res[-1] == res[a] * 2: B. if res[-1] == res[a] * 2:
a += 1 a += 1
elif res[-1] ==res[b] * 3: elif res[-1] ==res[b] * 3:
b += 1 b += 1
if res[-1] ==res[c] *5: elif res[-1] ==res[c] * 5:
c += 1 c += 1
C. if res[-1] == res[a] * 2: D. if res[-1] == res[a] * 2:
a += 1 a += 1
if res[-1] ==res[b] * 3: elif res[-1] ==res[b] * 3:
b += 1 b += 1
if res[-1] ==res[c] *5: else:
c += 1 c += 1
32. 2023 10 9
32. 5 “9**65” 37 67 Python
5
i,flag=100,False
while i>0 and not flag:
print(i//10,i%10)
j=90065+i*100 i-=1 if(j%37)*(j%67)==0:flag=True
A. B. C. D.
33. 2023 10 11
33. Python
a=['123','456','789']
s1='31,12,23,33'
s2=''
i=0
while ich=s1[i]
if ch!=',':
i+=1
p=int(si[i])
s2=a[p-1][int(ch)-1]+s2
i+=1
s2
A. '9843' B. '34' C. '3489' D. '43'
34. 2022 11 8
12/14
34. , , Python
for ch in s:
p+=str((int(ch)+key)%10)
else:
p=ch+p
“ym587”
A. ym785 B. ym709 C. my709 D.
my907
35. 2022 12 10
35. Python
while a!=b:
if a>b:
a = a - b
else:
b = b//2
print(b)
a b 22 16
A. 0 B. 1 C. 2 D. 16
36. 2022 12 11
36. a 10 150 ~190 )
170
[180,152,168,152,160,173,151,155,165,181]
5 173
from random import randint
a=[randint(150,190)for i in range(10)]
if max(a)<171:
171
else:
f=True;k=0
for i in range(10):
if a[i]>170:
if a[i]>a[k] :
k=i
f=False
print(a)
13/14
程序加框处代码有误,正确的语句为
A. a[i]C. a[i]37.【2022年12月强基联盟信息技术第6题】
37. 下列语句不.能.产生[0,10]之间随机偶数的语句是
A. int(random.random()*5)*2 B. andom.randint(0 , 5)*2
C. andom.choice([i for i in range(0,11,2)]) D. int(random.uniform(0.1 , 5.4))*2
14/14
7. Python 基础二(字符串处理、随机数、解析和枚举的应用、图像模块)
1 2 3 4 5 6 7 8
C A C B C B C D
9 10 11 12 13 14 15 16
ABC ABC D D D D A C
17 18 19 20 21 22 23 24
B A C D C A D C
25 26 27 28 29 30 31 32
C A C B D B C C
33 34 35 36 37
A C C B A
同课章节目录