已知列表 aList = [-1, -4, 6, 7.5, -2.3, 9, -11],则表达式[i for i in aList if i>0]的值为( )
A. [6, 9]
B. [7.5, 6, 9]
C. [6, 7.5, 9]
D. [9, 6, 7.5]
查看答案
以下这段代码,转换成列表推导式,最合适的是( )。 squared = [] for x in range(10): squared.append(x**2)
A. squared = [x**2 for x in range(10)]
B. squared = [x for x**2 in range(10)]
C. squared = [x for x in range(10)]
D. squared = [xfor x in range(10)**2 ]
x = [ i for i in range(0, 10, 3) if i % 2==0],则x为( )。
A. [0, 6]
B. [6]
C. [6,]
D. [4,6]
表达式[x for x in [1,2,3,4,5] if x < 3]的值为( )。
A. [1,2,3]
B. [1]
C. [1,2]
D. [0,1,2]
表达式[x*3 for x in range(1,10) if x%2==1]的值为( )。
A. [3,9,15,21]
B. [3,9,15,21,27]
C. [9,15,21,27]
D. [9,15,21]