掷骰子

时间:2020-03-04 18:01:11

标签: python data-visualization data-analysis pygal

为什么下面的代码中出现 +1

from die import Die
#from the file die.py import the Class Die

# create a D6.
die = Die()

# make some rolls, and store results in a list.
results = []
for roll_num in range(100):
    result = die.roll()# file die.py and function roll in that file.
    results.append(result) #adding to results every time that a die roll. die.roll()


# Analyze the results.

frequencies = []
for value in range(1,die.num_sides+1):
    frequency = results.count(value)
    frequencies.append(frequency)



print(frequencies)

我能够运行此代码,但我不知道为什么+1存在。

1 个答案:

答案 0 :(得分:0)

来自documentation

中的示例
requests