4、python要输入10个整数并进行存储的正确代码是 a、for i in 10: a[i]=input() b、for i in range(10): a[i]=input() c、for i in range(10): a.append(input()) d、a=[] for i in range(10): a.append(input())
5、学生信息存储在列表当中,下面哪个代码能实现寻找成绩为x的学生姓名的功能? a、stus=["zhangsan",86,"lisi",72,"wangwu",91,"taoyan",62] x=int(input("x:")) for i in range(len(stus)): if stus[i]==x: print(stus[i-1] " is in class") else: print("no this score in class") b、stus=["zhangsan",86,"lisi",72,"wangwu",91,"taoyan",62] x=int(input("x:")) for i in len(stus): if i%2==1: if x==stus[i]: break if i c、stus=["zhangsan",86,"lisi",72,"wangwu",91,"taoyan",62] x=int(input("x:")) for i in range(len(stus)): if i%2==1: if x==stus[i]: break if i d、stus=["zhangsan",86,"lisi",72,"wangwu",91,"taoyan",62] x=int(input("x:")) for i in range(len(stus)): if i%2==1: if x==stus[i]: break if i 第二章 穷举搜索课堂视频及课后作业
3、下面哪个是错误的用python实现存储n个人的姓名? a、names1=n*[0] for i in range(n): names1[i]=input('输入{}个人的姓名:'.format(i 1)) b、names2=[] for i in range(n): names.append(input('输入{}个人的姓名:'.format(i 1))) c、names3=[] for i in range(n): name=input('输入{}个人的姓名:'.format(i 1)) names3 =name d、names4=[] for i in range(n): names4[i]=input('输入{}个人的姓名:'.format(i 1)) e、names5=[] for i in range(n): name=input('输入{}个人的姓名:'.format(i 1)) names5 =[name]
4、已知有n个数据进行排序,下面能实现排序的是 a、data=[34,5,-6,12,87,29] data.sort() b、data=[34,5,-6,12,87,29] n=len(data) od=[] while idata[j 1]: t=data[j] data[j]=data[j 1] data[j 1]=t j =1 i =1 c、data=[34,5,-6,12,87,29] n=len(data) i=0 j=0 while idata[j 1]: t=data[j] data[j]=data[j 1] data[j 1]=t j =1 i =1 print(data) d、data=[34,5,-6,12,87,29] n=len(data) i=0 j=0 while idata[j]: t=data[i] data[i]=data[j] data[j]=t j =1 i =1