YLT Python 5级 2026.03
小明需要统计班级某次 Python 编程考试成绩在 1~100 分的学生人数,他想用 range 生成所有可能的分数值。以下代码正确的是()
scores = list(range(1, 100))
scores = list(range(1, 101))
scores = list(range(100))
scores = list(range(0, 101))
体育测试要求记录每分钟跳绳次数,体育委员用 range(0, 101, 5) 生成计数节点。这个范围会包含哪些数?()
0,5,10,...,95,100
0,5,10,...,95
5,10,...,95,100
5,10,...,95
元旦晚会需要编写从 10 到 1 的倒计时程序,正确的 range 表达式是?()
range(10, 1, -1)
range(10, -1, -1)
range(10, 0, -1)
range(10, 0, 1)
小明计划在 30 天的月份内进行健身,从第 1 天开始每隔 2 天锻炼一次(即第 1、4、7... 天)。正确的 range 表达式是?()
range(1, 30, 3)
range(1, 31, 3)
range(1, 30, 2)
range(1, 31, 2)
time 库是常用的 Python 标准库,以下代码是简单获取时间的方法。运行该程序后的输出结果可能是?()
import time
localtime = time.asctime(time.localtime(time.time()))
print('当前本地时间为:{}'.format(localtime))
当前本地时间为:2026 Feb 28 08:25:59
当前本地时间为:Feb 28 08:25:59 2026
当前本地时间为:Sat Feb 28 08:25:59
当前本地时间为:Sat Feb 28 08:25:59 2026
小明编写猜数字游戏,需生成 1 到 100 之间的随机整数(包含 1 和 100),正确的代码是?()
number = random.randint(1, 101)
number = random.uniform(1, 100)
number = random.randrange(1, 100)
number = random.randint(1, 100)
小明想用 Python 的 math 库计算“17 个苹果分给 4 个小朋友,每人最多能拿到多少个完整的苹果?”。以下哪个代码能正确解决问题?()
result = 17 / 4
import math
result = math.floor(17 / 4)
import math
result = math.ceil(17 / 4)
result = math.floor(17 / 4)
某 Python 程序如下:
a = [1, 2, 3]
b = [4, 5, 6]
t = list(map(lambda x, y: (x, y), a, b))
print(t)
上述程序执行后的结果是?()
[(1, 4), (2, 5), (3, 6)]
[1,2,3,4,5,6]
[[1,4],[2,5],[3,6]]
(1, 4), (2, 5), (3, 6)
在 Python 中,已知列表 a=[1,2,3],执行语句 a[1:2]=[7,8,9] 后,列表 a 为?()
[1,2,3]
[1,7,8,9,2,3]
[1,7,8,9,3]
[1,7,8,9]