######說明:答案僅提供參考
部分選擇題:
1、Python在內存中存儲了每個對象的引用計數(reference count)。如果計數值變成0,關於相應的對象會發生變化,描述錯誤的是?(B)
A. 相應的對象消失
B. 相應的對象仍然存在
C. 分配給該對象的內存會釋放出來
D. 相應的對象占用的空間會移交給操作系統
2、在Unix系統中,以下關於可執行Python腳本文件說法正確的是?(A)
A. 腳本文件的模式必須是可執行的
B. 第一行必須以#(#!/usr/local/bin/python)開頭
C. 腳本文件都可以直接執行
D. 以上說法都不正確
4、以下英文單詞中,不是Python保留字的是(A)
A. do
B. finally
C. with
D. in
8、以下哪個函數可以隨機化列表中的元素(C)
A. init
B. new
C. random
D. shuffle
10、以下哪個不是Python語言的標准庫(D)
A. datetime
B. random
C. sys
D. graph
13、在Python中,a=0011 1100,b=0000 1101,表達式a&b的結果是(A)
A. 0000 1100
B. 0011 1101
C. 0011 0001
D. 1100 0011
所有大題:
a,b = input().strip().split() count = 0 x_ = [-1,-1,-1] for i in range(int(a)+1,int(b)): if i*2 % 5 ==0: x_[count] = i count += 1
if count > 2: break
print(x_[0],x_[1],x_[2])
a,b = input().split() x = list(map(int,input().split())) temp_max = x[0]*x[1]*x[2] temp_index = 0 for i in range(0,len(x)-2): v = x[i] * x[i + 1] * x[i + 2] if v > temp_max: temp_max = v temp_index = i print(temp_max,temp_index+1)
str1 = input() judge = "_1234.exe" count = 0 num_list = [] for i in range(0,len(str1)-len(judge)+1): if str1[i:i+len(judge)] == judge: count += 1 num_list.append(i) if count == 0: print(count) else: print(count,end=" ") for j in num_list: print(j,end=" ")
n = int(input().strip()) metrix = [] for i in range(n): metrix.append(list(map(int,input().strip().split()))) length = 0 I = -1 J = -1 tag = 0 for j in range(1,n-1): #遍歷每一行
temp_length = 0 temp_i = -1 temp_j = -1
for k in range(n): #遍歷每一列
if metrix[j][k] > metrix[j-1][k] and metrix[j][k] > metrix[j+1][k]: temp_length += 1 temp_i = j temp_j = k if temp_length > length: length = temp_length I = temp_i J = temp_j tag = 1 #標記更新
else: temp_length = 0 temp_i = -1 temp_j = -1
if tag == 1: J = J - length + 1 tag = 0 for j in range(1,n-1): #遍歷每一列
temp_length = 0 temp_i = -1 #代表行
temp_j = -1 #代表列
for k in range(n): #遍歷每一行
if metrix[k][j] > metrix[k][j-1] and metrix[k][j] > metrix[k][j+1]: temp_length += 1 temp_i = k temp_j = j if temp_length > length: length = temp_length I = temp_i J = temp_j tag = 1
else: temp_length = 0 temp_i = -1 temp_j = -1
if tag == 1: I = I - length + 1 tag = 0 if length == 0: print(0,-1,-1) else: print(length,I+1,J+1)