第17164题 程序题
Python编程题:补全代码统计随机0/2序列中连续出现2022的次数

题目描述

Python等级考试五级编程题:寻找2022。 小明在玩一个数字游戏,该游戏要求每次随机生成100个0与2组成的数字序列。现在需要小明找出这个随机数字序列中能够连续组成2022这个数字序列的个数。请补全以下Python程序实现该功能:

import random as r
l = []
count = 0
for i in range(100):
    l.append(    ①     )
print(l)
for i in range(100):
    for j in range(100):
        if      ②      :
            if [2,0,2,2] ==    ③    :
                ④
print(count)
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
编辑模式
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析