组卷题库 > 高中信息技术试卷库
试题详情
有如下Python程序段:

import random

n = 8

a = [random.randint(0, 9)

for i in range(n)]

    for t in range(2):

        i = t + 1

        while i < n-1:

            if t % 2 == 0:

                if a[i-1] < a[i] and a[i] > a[i+1]:

                    i += 2

                else:

                    a[i] += random.randint(0, 9)

            else:

                if a[i-1] > a[i] and a[i] < a[i+1]:

                    i += 2

        else:

            a[i] = random.randint(0, 9)

运行后,数组a中的值可能是(   )

A、[8, 8, 3, 5, 4, 7, 3, 5]
B、[5, 11, 10, 18, 8, 9, 0, 2]
C、[1, 2, 1, 4, 0, 10, -1, 7]
D、[7, 12, 5, 17, 9, 19, -10, 8]
知识点
参考答案
采纳过本试题的试卷
教育网站链接