中国大学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)
- 下面代码的输出结果是 list1 = [(m,n) for m in 'ABC' for n in 'ABC' if m!=n] print(list1) A: [('A', 'C'), ('A', 'D'), ('B', 'C'), ('B', 'D')] B: 错误 C: [('A', 'B'), ('A', 'C'), ('B', 'A'), ('B', 'C'), ('C', 'A'), ('C', 'B')] D: ['AC', 'AD', 'BC', 'BD']
- 下面代码的输出结果是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' ] print(list1) A: AnBn B: mnmn C: ['An', 'Bn'] D: ["mn","mn"]
- 下面代码的输出结果是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']