首页 / 客观题库

Q80240 - 2026编程挑战赛Python提高组40

题目( 单选题 )

下述代码运行结果正确的是:

from itertools import combinations

from functools import reduce

from bisect import bisect_left

from collections import Counter

nums = [1, 2, 2, 3]

# ① 统计所有长度为2的组合(不去重)

pairs = list(combinations(nums, 2))

# ② 计算 nums 的乘积

product = reduce(lambda x, y: x * y, nums)

# ③ 在有序数组中查找插入位置

pos = bisect_left(nums, 2)

# ④ 统计元素频次

cnt = Counter(nums)

print(len(pairs), product, pos, cnt[2])

A 6 12 1 2

B 6 12 1 1

C 4 12 2 2

D 6 6 1 2

意见反馈

    最多上传3张图片,格式为JPG、PNG、JPEG,单张不超过5MB

    注册

    发送验证码

    密码必须包含数字、字母和特殊字符

    找回密码

    发送验证码

    密码必须包含数字、字母和特殊字符

    运行 ID:67149

    • 测试点1:Accepted
    • 用时:0 ms
    • 内存:288 kb
    • 测试点2:Accepted
    • 用时:0 ms
    • 内存:288 kb
    输入
    203
    输出
    203

    test

    测评信息

    错误.in文件下载

    错误.out文件下载

    运行 ID:67149

    2019-01-24 15:06:36