2、执行完下面代码后,输出的结果为( )
- ls = [6, 1, 8, 6, 9, 6]
- n = len(ls)
- for i in range(n):
- for j in range(i+1,n):
- if ls[j]>ls[i]:
- tmp = ls[i]
- ls[i] = ls[j]
- ls[j] = tmp
- print(ls)
A、[6,6,8,6,9,1]
B、[1,6,6,6,8,9]
C、[9,8,6,6,6,1]
D、程序报错无输出
2、执行完下面代码后,输出的结果为( )
- ls = [6, 1, 8, 6, 9, 6]
- n = len(ls)
- for i in range(n):
- for j in range(i+1,n):
- if ls[j]>ls[i]:
- tmp = ls[i]
- ls[i] = ls[j]
- ls[j] = tmp
- print(ls)
A、[6,6,8,6,9,1]
B、[1,6,6,6,8,9]
C、[9,8,6,6,6,1]
D、程序报错无输出
Scratch3.0 全国青少年软件编程等级考试 Python Scratch图形化一级 Scratch图形化四级 Scratch图形化三级 Scratch图形化二级 电子学会