a = [ 6 , 12 , 9 , 20 , 8 , 11 , 4 ]
for j in range( 1 , len( a ) ) :
if a[ j ] < a[ j - 1 ] :
a[ j ] = a[ j ] + a[ j - 1 ] ; a[ j - 1 ] = a[ j ] - a[ j - 1 ] ; a[ j ] = a[ j ] - a[ j - 1 ]
执行该段程序后,列表a的值是( )
彩票中心编写一个程序,功能为:随机生成7个不重复的中奖号码,并读取文件“彩票记录.txt”(该文件存储所有已售出的彩票号码),最后根据兑奖规则输出开奖结果,运行界面示例如下:
import random #随机生成7个[1,33]范围内不重复的中奖号码
flag= [ 0 ] * 34 ; data = [ 0 ] * 7
i = 0
while i < 7 :
t = random.randint( 1 , 33 )
if not flag[ t ]:
i = i + 1
flag [ t ] = 1
print("中奖号码:" , data)
#读取"彩票记录.txt"文件,存储到数组sale=[[12,8,9,23,1,16,7],[11,7,10,21,2,9,31]…],代码略。
#num[0]表示特等奖个数,num[i]表示i等奖个数
for i in range( len ( sale ) ) :
cnt = 0
for j in range ( 7 ) :
if sale[ i ][ j ] in data:
cnt += 1
num[] += 1
print("彩票开奖结果:")
for i in range( 7 ):
s="特等奖一等奖二等奖三等奖四等奖五等奖六等奖"
print(s[] , "产生:" , num[ i ] , "个")
A. Y="不及格" if X>=60: Y="及格" elif X>80: Y="优秀" | B. if X<=80: Y="及格" elif X<60: Y="不及格" else: Y="优秀" | C. if 60<=X<=80: Y="及格" else: Y="优秀" if X<60: Y="不及格" | D. if X>=60: Y="及格" if X>80: Y="优秀" else: Y="不及格" |
lst = [2,5,2,1]
y = [1,1,1,1]
n = len(lst)
for i in range(①____):
for j in range(②____):
if ③____:
y[j] = y[j] + 1
else
y[i] = y[i] + 1
上述程序段3个划线处的表达式分别为( )
s=input()
n=len(s);c=1;max=1
for i in range(1,n):
if (1)____:
c=c+1
if c>max:
max=c
else:
划线处可选代码为①c=1 ②c=0 ③s[i]<s[i+1] ④s[i]>s[i-1]
划线处正确的语句依次为( )
y="温度过高" if w<10:
y="温度过低"
else:
y="温度正常" print(y)
B . y="温度正常"if w>30:
y="温度过高"
elif w<10:
y="温度过低" print(y)
C . if w>30:y="温度过高" elif w<10:
y="温度过低" else:
y="温度正常"
print(y)
D . if w>30:y="温度过高" if w<10:
y="温度过低" if 10<=w<=30:
y="温度正常"
print(y)
def f(x):
for i in b:
if x==i:
return True
return False a=[2,0,9,3,10]
b=[10,9,16,2,7]
for i in a:
if f(i):
cnt+=1 print(cnt)
程序执行后的输出结果是( )