1.已知列表 x=list(range(9)),那么执行语句 de1x[:2]之后,x的值为(D)
A. [1,3,5,7,9]
B.[1,3,5,7]
C.[0,1,3,5,7]
D.[2,3,4,5,6,7,8]
2.len(range(1,10))的值是(B)
A.8 B.9 C.10 D.11
3.表达式”,".join(list)中 list 是列表类型,以下选项中对其功能的描述正确的是(D)
A.将逗号字符串增加到列表 list 中
B.在列表 list 每个元素后增加一个逗号
C.将列表所有元素连接成一个字符串,每个元素后增加一个逗号D.将列表所有元素连接成一个字符串,元素之间增加一个逗号
4.表达式[1.2.3]*3 的执行结果为(A)
A. [1,2.3,1.2,3.1.2.3]
B. {[1, 2,3],[1,2,3],[1,2,3]}
C.[1,2,3],[1,2.3],[1,2.3]
D.([1, 1, 1,2, 2, 2,3, 3,3])
5.假设列表对象 aList 的值为[3,4,5,6,7,9,11,13,15,17],那么切片 aList[3:7]得到的值是(B)
A. [5, 6, 7, 9, 11] B. [6, 7, 9, 11] C. [5,6, 7,9,] D. [7, 9, 11, 13]
8.已知 x=[3,7,5],那么执行语句 x=x.sort(reverse=True)之后,x的值为(B)
A. [3, 5, 7] B. [7. 5,3] C. None D . [3,7,5]
9.下面程序输出是什么?(D)
txt-["a, "b","c", "d","e”]
stop words=["d","i"]tx for x in txt if xnot in stop words
print(t)
A [ a ,"b ,"c ,"d","e ]
B [ a ,"b ,"c ,"d"]
C[a ,"b ,"c ]
D.[ a ,"b,"c","e”]
10.下面程序的输出是:(C)
ls=[ abcd", "ab","cd","cdab”]
n, m=0.0
for line in ls:
if "ab" and "cd" in line:
n+=1
m+=1
elif "ab" in line:
n+=1
elif "cd" in line:
m+=1
print(n,m)
A:3 3 B:3 4 C:43 D:4 4
b=[]
list1=list(range(2,100))
for i in list1:
for j in range(2,i):
if i%j==0:
break
else:
b.append(i)
for x in range(2,len(b)):
if b[x]-b[x-1]==2:
print(b[x-1],b[x])