小编Vik*_*tor的帖子

为什么总数不到1000?

当我运行下面的程序时,总数不是1000.我不知道出了什么问题.

在1000次掷骰子中,有:

  • 180比1
  • 136比2
  • 121为3
  • 97比4
  • 72比5
  • 60为6.

这总计为666卷骰子.

我想具体说一下,如果还有什么我不清楚的地方,请告诉我.谢谢大家:)

#this is a program that simulate how many times that there will be for every sides of a dice, when I trying to throw it 1,000 times.

from random import randrange

def toss():
    if randrange(6) == 0:
        return "1"
    elif randrange(6) ==1:
        return "2"
    elif randrange(6) ==2:
        return "3"
    elif randrange(6) ==3:
        return "4"
    elif randrange(6) ==4:
        return "5"
    elif randrange(6) ==5:
        return "6"

def roll_dice(n):
    count1 = 0
    count2 …
Run Code Online (Sandbox Code Playgroud)

python random simulation

-2
推荐指数
1
解决办法
71
查看次数

标签 统计

python ×1

random ×1

simulation ×1