输入学生姓名,增加到一个列表st中,直到输入的姓名为空为止,最后输出st。
st=[]
while True:
s=input()
if s!="":
__________
else:
break
print(st)
st=[]
while True:
s=input()
if s!="":
__________
else:
break
print(st)
举一反三
- 输入学生姓名,增加到一个列表st中,直到输入的姓名为空为止,最后输出st。s=[]while True:s=input()if s!="":__________else:breakprint(st) A: s.append(st) B: st.add(s) C: st.insert(s) D: st.append(s)
- 一个文本文件test.txt的一行存储5个整数如下:1 3 56 67 34数之间用空格隔开,要读出这些整数的函数正确的是: A: def read(): f=open("test.txt","rt") while True: s=f.read() if s!="": print(s) else: break f.close() B: def read(): f=open("test.txt","rt") while True: s=f.readline() if s!="": print(s) else: break f.close() C: def read(): f=open("test.txt","rt") st=f.readlines() for s in st: print(s) f.close() D: def read(): f=open("test.txt","rt") s=f.readline() st=s.splist(" ") for s in st: print(s) f.close()
- 个文本文件test.txt的一行存储5个整数如下:1 3 56 67 34数之间用空格隔开,要读出这些整数的函数正确的是: A: def read():f=open("test.txt","rt")st=f.readlines()for s in st:print(s)f.close() B: def read():f=open("test.txt","rt")while true:s=f.read()if s!="":print(s)else:breakf.close() C: def read():f=open("test.txt","rt")while true:s=f.readline()if s!="":print(s)else:breakf.close() D: def read():f=open("test.txt","rt")s=f.readline()st=s.splist(" ")for s in st:print(s)f.close()
- 写出下面程序的输出结果:sub(ints,intm,intn,charst[]){intp,q,t;t=st[s];p=s;while(1){q=(p+m)%n;if(q==s)break;st[p]=st[q];p=q;}st[p]=t;}main(){charb[]="0123456789";sub(1,2,10,b);puts(b);}
- 给出如下代码st="Hello,World" , 可以输出“World”子串的是( ) A: print(st[5:0]) B: print(st[6:]) C: print(st[5:11]) D: print(st[6:0])