单项选择题
假设特等奖、一等奖、二等奖、三等奖的中奖概率分别为1%,6%,28%,65%。下面的程序模拟100次抽奖结果,统计每个奖项的中奖次数。提示:程序生成100个[0,1]区间随机数,通过判断每个随机数落在哪个中奖区间内完成统计。
下面应填入的代码是( )。
import random
d_prize={ '特等奖': (0,0.01), '一等奖': (0.01,0.07), '二等奖': (0.07,0.35), '三等奖': (0.35,1.0) }
result = dict()
for i in range(100):
空1
for key,value in d_prize.items():
if value[0]<=num
空2
for item in result.items():
print(item)
知识点:random库、字典
A、空1:num = random.uniform(0,1)
空2:result[key] = result.get(key,0)+1
B、空1:num = random.randint(0,1)
空2:result[key] = result[key]+1
C、空1:num = random.randint(0,1)
空2:result[key] = result.get(key,0)+1
D、空1:num = random.uniform(0,1)
空2:result[key] = result[key]+1