数据类型和运算
1. 表达式 'a' < 'b' 的结果是?
(a) 'a'
(b) True
(c) False
(d) Error
2. 下面表达式 2 * ['1', '3'] 的结果是多少?
(a) [2, 6]
(b) ['2', '6']
(c) ['1', '1', '3', '3']
(d) ['1', '3', '1', '3']
(e) Error
3. 下面表达式 '2' + ['1', '3'] 的结果是多少?
(a) [3, 5]
(b) ['3', '5']
(c) ['21', '23']
(d) ['2', '1', '3']
(e) Error
4. 下面表达式 list('2') + ['1', '3'] 的结果是多少?
(a) [3, 5]
(b) ['3', '5']
(c) ['21', '23']
(d) ['2', '1', '3']
(e) Error
5. 下面表达式 list('a') + ['d', 'e'] 的结果是多少?
(a) ['ad', 'ae']
(b) ['a', 'd', 'e']
(c) ['a', ['d', 'e']]
(d) [['a'], 'd', 'e']
(e) Error
6. 下面表达式 '2' * ['4', '6'] 的结果是多少?
(a) [8, 12]
(b) ['8', '12']
(c) ['4', '4', '6', '6']
(d) ['4', '6', '4', '6']
(e) Error
7. 下面表达式 '54' + '28' 的结果是多少?
(a) ['54', '28']
(b) 82
(c) '5428'
(d) ['5428']
(e) Error
8. 下面表达式 ['8', '5'] + [7] 的结果是多少?
(a) [15, 12]
(b) ['8', '5', 7]
(c) [8, 5, 7]
(d) ['8'7, '5'7]
(e) Error
9. 下面表达式 2 * ['1', '3'] 的结果是多少?
(a) [2, 6]
(b) ['2', '6']
(c) ['1', '1', '3', '3']
(d) ['1', '3', '1', '3']
(e) Error
10. 下面表达式 '2' + ['1', '3'] 的结果是多少?
(a) [3, 5]
(b) ['3', '5']
(c) ['21', '23']
(d) ['2', '1', '3']
(e) Error
11. 下面表达式 list('2') + ['1', '3'] 的结果是多少?
(a) [3, 5]
(b) ['3', '5']
(c) ['21', '23']
(d) ['2', '1', '3']
(e) Error
12. 下面表达式 (1, 2) + (3, 4) 的结果是多少?
(a) (1, 2, 3, 4)
(b) (4, 6)
(c) (4, 5, 5, 6)
(d) Error
13. 下面表达式 (5,4) + ((3)) 的结果是多少?
(a) (5, 4, 3)
(b) (5, 4, (3))
(c) (8, 7)
(d) (9, 3)
(e) Error
14. 下面表达式 1, + 2, + 3, 的结果是多少?
(a) 6
(b) (6,)
(c) (1, 2, 3)
(d) Error
15. 下面表达式 ('a', 'c') + ('b', 'd') 的结果是多少?
(a) ('a', 'c', 'b', 'd')
(b) ('a', 'b', 'c', 'd')
(c) ('ab', 'cd')
(d) 'acbd'
(e) Error
16. 下面表达式 4*'fox'/4 的结果是多少?
(a) 'fox'
(b) 'foxfoxfoxfox'
(c) 'foxfoxfoxfox/4'
(d) Error
17. 给定如下代码:
x = input("Please enter the first number: ")
y = input("Please enter the second number: ")
print ("x + y =", x + y)
假设用户分别输入 2 和 5,输出是什么?
(a) x + y = x + y
(b) x + y = 25
(c) x + y = 7
(d) Error
18. 给定如下代码:
x = input("Please enter a number: ")
y = input("Please enter a second number: ")
print ("x / y =", x / y)
假设用户分别输入 10 和 4,输出是什么?
(a) x / y = 2
(b) x / y = 2.5
(c) x / y = 0.5
(d) Error
19. 下面表达式 list(('a', 'c') + (1,2,)) 的结果是多少?
(a) ('a', 'c', 1, 2)
(b) ('a', 'c', 1, 2,)
(c) ['a', 'c', 1, 2]
(d) ['a', 'c', 1, 2,]
(e) Error
20. 执行如下语句后,y 的值是多少?
x = [1, 2, 3, [4, 5, 6]]
y = x[3, 2]
(a) 5
(b) 6
(c) 3
(d) [4, 5]
(e) Error
21. 下面表达式 [1, 2] + [2, 3] 的结果是多少?
(a) [1, 2, 2, 3]
(b) [1, 2, 3]
(c) [3, 5]
(d) Error
22. 下面表达式 (1, 'a') + (2, 'b') 的结果是多少?
(a) {1: 'a', 2: 'b'}
(b) (1, 'a', 2, 'b')
(c) (3, 'ab')
(d) [(1, 'a'), (2, 'b')]
(e) Error
23. 给定如下代码:
x = input("Please enter the first number: ")
y = input("Please enter the second number: ")
print ("x - y =", x - y)
假设用户分别输入 7 和 3,输出是什么?
(a) x - y = x - y
(b) x - y = 7 - 3
(c) x - y = 4
(d) Error
24. 下面表达式 (2,3) + (4) 的结果是多少?
(a) (2,3,4)
(b) (2,3)
(c) (6,7)
(d) Error
25. 下面表达式 ['g', 'y'] < ['b', 'd'] 的结果是多少?
(a) True
(b) False
(c) ''
(d) Error
26. 执行如下循环时会打印什么?(注意 \n 对应换行)
for a,b in [(3,4),(6,7)]:
print (a,b)
(a) (3,4) 0\n(6,7) 1
(b) 3 0 4 1 6 2 7 3
(c) 3 4\n6 7
(d) None of the above
27. 执行如下语句后,y 的值是多少?
x = [2,[3,5,8],7]
y = x[1,2]
(a) 5
(b) 8
(c) 7
(d) Error
28. 表达式 (7,3,(6,)) + (9,(5)) 的结果是多少?
(a) (7, 3, 6, 9, 5)
(b) (7, 3, (6,), 9, (5))
(c) (7, 3, (6,), (9, (5)))
(d) (7, 3, (6,), 9, 5)
(e) None of the other choices are correct
29. 下面表达式 ['ab'] <= ['ba'] 的结果是多少?
(a) Error
(b) 'ba'
(c) 'ab'
(d) False
(e) True
30. 执行如下语句后,a 的值是多少?
x = [1, 'a', '\t bc'.strip()]
y = ['d', 'g', 'f']
z = x + y
a = z[2]
(a) '\tbc'
(b) 'bc'
(c) Error
(d) '\t bcf'
(e) '\tbc'
31. 表达式 max(2,4) < min(5,[6,3][1]) 的结果是?
(a) True
(b) False
(c) Error
(d) None of the other choices are correct
32. 下面表达式 (2,9) + ([7]) 的结果是多少?
(a) (2,9,[7])
(b) (2,9,([7]))
(c) (2,9,7)
(d) Error
(e) None of the other choices are correct
33. 下面表达式 ['grue'] <= ['cat'] 的结果是多少?
(a) True
(b) False
(c) ['grue']
(d) Error
(e) None of the other choices are correct
34. 执行如下语句后,a 的值是多少?
x = [3, '7', '\n d r'.split()]
a = x[2][2]
(a) 'd'
(b) 'r'
(c) 'd r'
(d) Error
(e) None of the other choices are correct
35. 表达式 max(1.2,4//3) < min(7-2**3,1.1) 的结果是?
(a) True
(b) False
(c) Error
(d) None of the other choices are correct
36. 下面表达式 (1, 2) + (2, ) 的结果是多少?
(a) (1, 2)
(b) (3, 2)
(c) (1, 2, 2)
(d) [(1, 2), (2, )]
(e) Error
37. 下面表达式 [1, 2] + [1, 2, 3] 的结果是多少?
(a) [1, 2, 3]
(b) [2, 4, 3]
(c) [1, 1, 2, 2, 3]
(d) [1, 2, 1, 2, 3]
(e) Error
38. 执行如下语句的结果是什么?
x = (1, 2)
x += (3, 4)
(a) Tuples are immutable, the += operator will cause an error.
(b) The second statement will add the values 3 and 4 to the tuple stored in x.
(c) Tuples are immutable, the second statement will assign the tuple (3, 4) to x.
(d) The second statement will create a new tuple that contains the contents of x and the tuple (3, 4).