下面代码的输出结果是list1 = [(m,n) for m in 'ABC' for n in 'ABC' if m!=n]print(list1)
A: 错误
B: ['AC', 'AD', 'BC', 'BD']
C: [('A', 'B'), ('A', 'C'), ('B', 'A'), ('B', 'C'), ('C', 'A'), ('C', 'B')]
D: [('A', 'C'), ('A', 'D'), ('B', 'C'), ('B', 'D')]
A: 错误
B: ['AC', 'AD', 'BC', 'BD']
C: [('A', 'B'), ('A', 'C'), ('B', 'A'), ('B', 'C'), ('C', 'A'), ('C', 'B')]
D: [('A', 'C'), ('A', 'D'), ('B', 'C'), ('B', 'D')]
举一反三
- 下面代码的输出结果是list1 = [(m,n) for m in 'ABC' for n in 'ABC' if m!=n]print(list1) A: 错误 B: ['AC', 'AD', 'BC', 'BD'] C: [('A', 'B'), ('A', 'C'), ('B', 'A'), ('B', 'C'), ('C', 'A'), ('C', 'B')] D: [('A', 'C'), ('A', 'D'), ('B', 'C'), ('B', 'D')]
- 下面代码的输出结果是list1 = [(m,n) for m in 'AB' for n in 'CD']print(list1) A: [('A', 'C'), ('A', 'D'), ('B', 'C'), ('B', 'D')] B: [‘A’,’B’,’C’,’D’] C: 错误 D: ['AC', 'AD', 'BC', 'BD']
- 中国大学MOOC: 下面代码的输出结果是list1 = [(m,n) for m in ABC for n in ABC if m!=n]print(list1)
- 下面代码的输出结果是list1 = [m+n for m in 'AB' for n in 'CD']print(list1) A: ['AC', 'AD', 'BC', 'BD'] B: 错误 C: ABCD D: AABBCCDD
- 下面代码的输出结果是( )。 list1 = [m+n for m in 'AB' for n in 'CD']print(list1)