注,以下答案仅为个人所做,
不代表标准答案
有一部分为非python题目,按照命题趋势,应该是不会出了。
单选
1.以下变量的类型是字典的是: ( ) A.‘aab’ B. {2:1, ‘r’:1} C. [2,5, ‘r’] D. 123
2.以下变量类型是字符串的是: ( ) A.‘124’ B. lol C.False D. [‘a’, ‘b’]
3.列表a=[1],b=[2,3],执行a. extend(b)后,a的值为( ) [1,2,3] B.[1,[2,3]] C.[1,2] D.以上都不对
a=[1]
b=[2,3]
a.append(b)
print(a)
4.a=“xiaozhupeiqi” print a.find(“z”)的结果: ( ) A.5 B.4 C.-1 D.以上都不对
a="xiaozhupeiqi"
print(a.find("z"))
5. a=0 while a<10: a=a+3 print a 结果为( ) A.10 B.9 C.11 D.12
a=0
while a<10:
a=a+3
print(a)
6.a=“1:5,1:4”,问a的变量类型? ( ) 列表 B.字典 C.字符串 D.整数
a="1:5,1:4"
print(type(a))
7.下面哪些是合法变量名? ( ) A.def B.def1 C.1def D.”def”
8.for i in range(0,5): for j in range(2,6): print i,j 请问以上程序中print 总共执行了多少次( ) A. 5 B. 4 C. 20 D.25
for i in range(0,5):
for j in range(2,6):
pass
print(i,j)
9. a={5:[2,1],2:[7,9,0]} print a[2][1] 该程序的输出结果是( ) A.1, B .7 C .9 D. None
a={5:[2,1],2:[7,9,0]}
print(a[5][1])
10.下属语句执行后结果为( ) sum=1 for x in range(5): sum*=x print sum A.0 B.120 C.24 D.55
sum=1
for x in range(5):
sum*=x
print(sum)
填空
1.print “a” in “abc” 输出结果:____________
print("a" in "abc")
2.print 3**2+6/4 输出结果:____________
print(3**2+6/4)
3.a={1:2,2:4} print a.values() 此程序的运行结果:_______
a={1:2,2:4}
print(a.values())
4.a=[2,1,4,2,2,4,5] b=0 for i in a: if i==2: b=b+1 print b 输出结果:________
a=[2,1,4,2,2,4,5]
b=0
for i in a:
if i==2:
b=b+1
print(b)
5.以下程序运行结果:________ a =[3,1,4,8,1] print a.count(1)/float(len(a))
a=[3,1,4,8,1]
print(a.count(1)/float(len(a)))
6. k=[3,2,5,6,7] k1=[] for i in range(1,len(k)): k1.append(k[i]-k[i-1]) print k1 以上程序的运行结果为(注意输出格式):______________
全部代码
a=[1]
b=[2,3]
a.append(b)
print(a)
a="xiaozhupeiqi"
print(a.find("z"))
a=0
while a<10:
a=a+3
print(a)
a="1:5,1:4"
print(type(a))
for i in range(0,5):
for j in range(2,6):
pass
print(i,j)
a={5:[2,1],2:[7,9,0]}
print(a[5][1])
sum=1
for x in range(5):
sum*=x
print(sum)
print("a" in "abc")
print(3**2+6/4)
a={1:2,2:4}
print(a.values())
a=[2,1,4,2,2,4,5]
b=0
for i in a:
if i==2:
b=b+1
print(b)
a=[3,1,4,8,1]
print(a.count(1)/float(len(a)))
k=[3,2,5,6,7]
k1=[]
for i in range(1,len(k)):
k1.append(k[i]-k[i-1])
print(k1)
真题文件
链接:https://pan.baidu.com/s/14uPhdPDHs7oM5V_ORgS_wA 提取码:dsm7
程序设计题
见博客:https://blog.csdn.net/weixin_43956523/article/details/119255302
|