資源簡介 Python 21. 2022 5 101. n 9 99 Pythonn=2022 ; s=0 ; t =0while n>0:if s%9==0:9else:9s=s+tn=n//10t=n %10A. B. C. D.2. 2022 5 122. Python :for i in range(1,len(s)):if t>=0 and s[i]==a[t]:t=t-1else:t=t+1a[t]=s[i], , tA. ++**+ B. +*+** C. *+**+ D.*++*+3. 2022 6 123. Python- 1]]while t!= - 1:s=d[t][1]outs=chr((ord(d[t][0])-97+d[s][0])%26+97)+outst=d[s][1]print(outs)“a ” ASCII 97A.yuzb B.bzyu C.kmddD.ddmk1/144. 2022 6 84. Pythonn=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+=1else:n-=1print(n)nA. 0 B. 1 C. -1 D. 25. 2022 6 105. s 2 3 5 8 , s Python1 2 3 5def sum(n):s=0 ; x=2 ; y=1for i in range(0, n):return sprint(sum(n))x=x+y y=x s=s+x/y y=x-yA. B. C. D.6. 2022 6 116. (DNA) DNA4 (A) (G) (T) (C)A T G C :import randomDNA=['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/14D. s=random. choice(DNA)+s t= t + match[i]7. 2022 6 127. Pythona = [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 = sprint(t)A. 6 B. -10 C. 15 D. 338. 2022 68. a ( b8 a 8 b:from PIL import Imageimport matplotlib. pyplot as pltimg = Image.open .convertpix = img.loadfor row in range img.width :for col in range img. height :if pix[row,col] >128:pix[row,col] = 0else:pix[row,col] = 1plt.imshowplt.axisplt.showA. :“ . jpg” B. 128 50C. plt. show() D.3/149. 2022 99. random bbA. random. choice(b) B. random. sample(b,1) C. b[random. randint(0,2)] D.b[random. random()*3]10. 2022 1010. : ;; Pythonidiom(x) xws = []ws. append (head)……c = 0while ( ) and idiom(w):c += 1ws. append(w)print(ws): ”,c)A. len(w) == 4 and w[0] in ws[len(ws) - 1] and w not in wsB. 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 ws11. 2022 6 611 pythondef encrypt(code,key):for s in code:s1= ord('a')+((ord(s)-ord('a'))+key)%26code_new+=chr(s1)return code_newprint(encrypt(code,2))AB code App , crrC (int(s)+key)%10D ord('a')+((ord(s)-ord('a'))-key)%2612. 2022 7 104/1412. Pythonp='Tel-114'c=' 'for ch in p:c+=str(9-int(ch))c+=chr(ord(ch)-else:c+=chprint(c)A. tEL-885 B. tEL-114 C. TEL-114 D. TEL-88513. 2022 8 A9 813 Pythons =f = Truefor i in range(0,len(s)//2):if s[i] != s[len(s)-i-1]:f = Falsebreakprint(f)“True”A onion B hello C 278D 11114. 2022 8 A9 1014 Pythonm = cnt = 1for i in range(1,len(s)):if s[i]>s[i-1]:cnt += 1if cnt > m :m = cntelse:cnt = 1print(m)A s B sC s D s15. 2022 8 A9 125/1415 Pythonfrom random import randomi = 0a = [0]*6while i<=5:a[i] = (int(random()*6+5))*(i%2+1)for j in range(i):if a[j] == a[i]:i = i-1breaki=i+1aA [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 816 Python;for i in range(len(s)):x=chr(((ord(s[i])-95))%26+97) # ASCII 97x=chr(((ord(s[i])-41))%26+65) # ASCII 65flag=Falseelse:x=s[i];flag=Truek=k+xprint(k)A ZAyb#dK B yzYZ#Dm C zaYB#Dk D zaYZ#Dm17. 2022 8 917. Nilakantha Pi(Pi(n Pi( )s=0;n=0;i=0nfor i in range(2,2*n+1, ):s=s+print (s)pi = 3 + s * 4print(pi)A. 1 (-1)**(i//2+1)/(i*(i+1)*(i+2)) B. 26/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 1018. “ ” 10; 15 ( )import random import time import os10for i in range(10):) #time. sleep(10) # 10#n=0 # 0t2=random. sample( ,5) # 5for i in t2: # 5#if i==n=n+1 # 1\n #\nA. 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 1219.import randoma=[0]*6for i in range(6):a[i]=random. randint(1,5)*2+1i=0while i<5:if a[i]>a[i+1]:a[i],a[i+1]=a[i+1],a[i]else:a[i]+=1i+=1print(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 97/1420. Pythonfor i in range ( len ( s ) ) :c = s [ i ]if i % 2 == 0:c = chr ( ( ord ( c ) – –else:c = c . upper ( ) # x . upper( ) xans += cprint ( ans )A. PYwHtN B. YrHkN C. PaTIOt D. PYrHkN21. 2022 9 521. Python :f=[0]* 128for i in n:f[ord(i)]+=1for i in n:if (f[ord(i)]==1):print(i,ace3,A. abecb3b B. bacea3b C. babcbe3 D. b3ace3d22. 2022 9 822. Python :t=[1 3 2]for i in range (1en(s)):m= t[i % len(t)]n= ord(s[i]) + mres = res + chr(n)print (res)A. Dkkod B. Ciknb C. DkjoD D. Cijob23. 2022 10 1023. Pythonk=3sum,j,c=0,0,08/14flag=Falsefor ch in s:c=c*10+int(ch)j+=1flag=Trueelse:if j==k and flag:sum+=cflag=Falsej=0;c=0s sumA.18 B.101 C. 119 D.32124. 2022 11 1024. nn ab b[i][0] b[i][1]Pythonp = len(b)i = 0while i < p:for j in range(n):if b[i][0]==a[j]:print(b[i][1])i = i + 1A.B. pC. nD.25. 2022 11 1225.from random import randintk = randint(1, 4)for i in range(k):j = i + 1while j < len(s) and s[j] > s[i]:j += 1if j < len(s):s = s[:j] + s[j + 1:]9/14else:s = s[:len(s) - 1]print(s)s26. 2022 11 1126. 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 1027. pythonn=int(input())s=0i=1while i*i<=n:if i==n//i:s=s+1elif n%i==0:s=s+2i=i+1print(s)16A. 3 B. 4 C. 5 D. 628. 2022 11 828. pythonfor i in s:if i inans = ans + ielse:ans = i + ansprint(ans)10/14A. 10 B. 31024 C. 42013 D. 4321029. 2022 11 1129. pythonfrom random import randinta ,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) == 0len(b) > 0 len(b) == 0 b[0]A. B. C. D.30. 2022 11 9+1 930. Python-for ch in p:c+=str(9-int(ch))c+= chr(ord(ch)-else:c+=chprint(c)A. tEL-678 B. TEL-678 C. TEL-321 D. tEL-32131. 2022 1031. 2 3 5 (Ugly Number), 20 “2, 3, 4, 5, 6, 8, 9, 10,12, 15, 16, 18, 20” xx = 20;res = [1];a = b = c = 0while res[-1] < x:res. append(min(res[a] * 2, res[b] * 3, res[c] * 5))11/14print(res[1:])A. if res[-1] == res[a] * 2: B. if res[-1] == res[a] * 2:a += 1 a += 1elif res[-1] ==res[b] * 3: elif res[-1] ==res[b] * 3:b += 1 b += 1if res[-1] ==res[c] *5: elif res[-1] ==res[c] * 5:c += 1 c += 1C. if res[-1] == res[a] * 2: D. if res[-1] == res[a] * 2:a += 1 a += 1if res[-1] ==res[b] * 3: elif res[-1] ==res[b] * 3:b += 1 b += 1if res[-1] ==res[c] *5: else:c += 1 c += 132. 2023 10 932. 5 “9**65” 37 67 Python5i,flag=100,Falsewhile i>0 and not flag:print(i//10,i%10)j=90065+i*100 i-=1 if(j%37)*(j%67)==0:flag=TrueA. B. C. D.33. 2023 10 1133. Pythona=['123','456','789']s1='31,12,23,33's2=''i=0while ich=s1[i]if ch!=',':i+=1p=int(si[i])s2=a[p-1][int(ch)-1]+s2i+=1s2A. '9843' B. '34' C. '3489' D. '43'34. 2022 11 812/1434. , , Pythonfor ch in s:p+=str((int(ch)+key)%10)else:p=ch+p“ym587”A. ym785 B. ym709 C. my709 D.my90735. 2022 12 1035. Pythonwhile a!=b:if a>b:a = a - belse:b = b//2print(b)a b 22 16A. 0 B. 1 C. 2 D. 1636. 2022 12 1136. a 10 150 ~190 )170[180,152,168,152,160,173,151,155,165,181]5 173from random import randinta=[randint(150,190)for i in range(10)]if max(a)<171:171else:f=True;k=0for i in range(10):if a[i]>170:if a[i]>a[k] :k=if=Falseprint(a)13/14程序加框處代碼有誤,正確的語句為A. a[i]C. a[i]37.【2022年12月強(qiáng)基聯(lián)盟信息技術(shù)第6題】37. 下列語句不.能.產(chǎn)生[0,10]之間隨機(jī)偶數(shù)的語句是A. int(random.random()*5)*2 B. andom.randint(0 , 5)*2C. andom.choice([i for i in range(0,11,2)]) D. int(random.uniform(0.1 , 5.4))*214/147. Python 基礎(chǔ)二(字符串處理、隨機(jī)數(shù)、解析和枚舉的應(yīng)用、圖像模塊)1 2 3 4 5 6 7 8C A C B C B C D9 10 11 12 13 14 15 16ABC ABC D D D D A C17 18 19 20 21 22 23 24B A C D C A D C25 26 27 28 29 30 31 32C A C B D B C C33 34 35 36 37A C C B A 展開更多...... 收起↑ 資源預(yù)覽 縮略圖、資源來源于二一教育資源庫