下面程序运行后输出是_______。a = [1, 2, 3, 4, [5, 6], [7, 8, 9]]s = 0for row in a: if type(row)==list: for elem in row: s += elem else: s+=rowprint(s)
举一反三
- 下面代码的输出结果是:a = [[1,1,1], [2,2,2], [3,3,3]]s = 0for c in a: for j in range(3): s += c[j]print(s) A: 3 B: 9 C: 18 D: 6
- 以下代码的输出结果是______。a = [[1,2,3], [4,5,6], [7,8,9]]s = 0for c in a:for j in range(3):s += c[j]print(s) A: 6 B: 45 C: 21 D: 0
- 下面代码的输出结果是( )。 a=[[1,2,3],[4,5,6],[7,8,9]] s=0 for i in range(2): for j in range(3): s+=a[i][j] print(s)[/i] A: 15 B: 6 C: 45 D: 21
- 下面代码的输出结果是 a = [[1,2,3], [4,5,6], [7,8,9]]s = 0for c in a: for j in range(3): s += c[j]print(s) A: 24 B: 以上答案都不对 C: 45 D: 0
- 已知bb= [[1,2,3],[4,5,6],[7,8,9]],则表达式 [row[col] for row in bb for col in range(len(row)) if col==1 ] 的值为________。() A: [2, 5, 8] B: [1,4,7] C: [1,2,3] D: [3,6,9]