列出 30 到 35 之间的 10 个随机实数

Make a list of 10 random reals between 30 and 35

如果可能请帮忙。我希望完成这段代码来编写一个程序,该程序生成 30 到 35 之间的 10 个随机实数,整个组周围有方括号 - 我只能让它们变成单个列表出现,但它们需要全部相同列表。 这是我目前的解决方案:

import random

def problem2_4():
    random.seed(70)
    ct = 0
    while ct <= 9:
        a = random.random()*5
        a = a+30
        a = [a]
        print(a,end=" ")
        ct = ct+1

但是当你执行它时,它看起来像这样:

problem2_4()

[34.54884618961936, 31.470395203793395, 32.297169396656095, 30.681793552717807, 34.97530360173135, 30.773219981037737, 33.36969776732032, 32.990127772708405, 33.57311858494461, 32.052629620057274]

试试这个

a = [random.uniform(30,35) for x in range(10)]
print(a)