单选题(每题3分,共10题30分):
1、下列程序输出的结果为:( )
for i in range(3):
for j in range(3):
print(i, end="")
A. 012012012
B. 000111222
C. 123123123
D. 111222333
答案 B
2、在Python中,random模块用于生成随机数。下列函数中是生
成随机整数的为:( )
A. randint.random()
B. random.random()
C. random.randint()
D. random.choice()
答案C
3、如果a=2,b=3,c=4;那么a>c or a<b 输出结果是( )
A. True
B. False
C. true
D. false
答案A
4、以下代码运行后,结果为( )
a = 10 % 3
b = int(2.9)
c = 3
print(a+b**(c-a)/2)
A. 3.0
B. 4.0
C. 5.0
D. 5.5
答案A
5、下列一段代码:
while True:
a = int(input("请输入你的得分: "))
if a <= 90:
print("继续努力! ")
continue
else:
print("真不错!")
break
能让循环终止的输入项为: ( )
A.90
B.95
C.89
D.70
答案B
6、观察下列代码,结果运行正确的为:( )
keys1 = ["一班", "二班"]
keys2 = ["学号", "成绩"]
info_dict = {}
for key1 in keys1:
info_dict[key1] = {}
for key2 in keys2:
info_dict[key1][key2] = "xx"
A.{"一班": "学号", "二班": "成绩"}
B.{"一班": {"学号":"xx", "成绩": "xx"}, "二班": {"学号
": "xx","成绩": "xx"}}
C.{"一班": {"学号": "xx"}, "二班":{"成绩": "xx"}}
D.{{"学号": "xx","成绩": "xx"}, {"学号": "xx", "成绩
":"xx"}}
答案C
7、运行下方代码段,输出的结果为:( )
import turtle
for i in range(3):
turtle.backward(100)
turtle.right(90)
turtle.done()
A.
B.
C.
D.
答案A
8、以下程序段的运行结果是?( )
s = 0
i = 0
while i <= 10:
i += 1
if i%2 == 0:
continue
s += i
print(s)
A.10
B.36
C.55
D.25
答案B
9、content.txt中的内容为字符串“ happy birthday!”,运行下
方代码后输出的结果为:( )
f = open("content.txt", "r")
for i in f.readlines():
print(i, end="")
A.happy
B.happy birthday!
C.happybirthday!
D.happy
birthday!\n
答案:B
10、运行下列代码,输出结果正确的选项为:( )
list1 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
list2 = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i
Python样题 - 小学高年级组,bcsp-X真题,北京中小学信息学能力测评,Python题库