python3解释器执行下面的示例代码后,list1的结果是( ):>;>;>; list1 = [1,2,[3,4]]>;>;>; list2 = copy.deepcopy(list1)>;>;>; list2[2] = 'a'>;>;>; list1
A: [1, 2, ['a', 4]]
B: [1, 2, 'a']
C: [1, 2, [3, 4]]
D: 报错
A: [1, 2, ['a', 4]]
B: [1, 2, 'a']
C: [1, 2, [3, 4]]
D: 报错
举一反三
- 执行下列代码后,变量list2的值将改变为哪个选项?[br][/br] list1 = [1, 2, 3] list2 = [] for element in list1: list2.append(element) list1 = [4, 5, 6] A: [1, 2, 3] B: [4, 5, 6] C: [1, 2, 3, 4, 5, 6] D: 没有;该代码无效
- 有两个列表list1和list2,请返回它们的笛卡尔积,列表中的每个元素都是一个元组。例如list1=[1,2,3];list2=[3,4]则结果是:[(1, 3), (1, 4), (2, 3), (2, 4), (3, 3), (3, 4)]
- 代码如下 #函数定义 def chanageList(list): list.append(" end") print("list",list) #调用 strs =['1','2'] chanageList() print("strs",strs) 下面对 strs 和 list 的值输出正确的是 A: strs ['1','2'] list ['1','2'] B: strs ['1','2','end'] list ['1','2','end'] C: list ['1','2','end'] strs ['1','2','end'] D: list ['1','2','end'] strs ['1','2']
- 已知列表 list1 = [1, 2, 3],那么执行语句[list1.append('ii') for ii in range(1,5,2)]之后,list1的值为________。() A: [1, 2, 3, 'i', 'i'] B: [1, 2, 3, 'ii', 'ii'] C: [1, 2, 3, 1, 3] D: [1, 2, 3, '1', '3']
- dict={'a':1, 'b':2, 'c':3} str=list(dict.keys())[list(dict.values()).index(2)] print(str) 输出结果是( ) A: a B: C: c D: 2