heads = 0
我需要用和模拟掷硬币tails = 1
。并且每次生成一个介于 1 和 0 之间的随机数时,都需要在数组中递增和更新正面或反面。下面是我的代码:
import numpy, random
flips = numpy.array([0,0])
coin = heads = tails = 0
for i in range(10):
coin = random.randint(0,1)
if coin == 0:
heads += 1
(Now at this point, I want to update the second position of the array because that represents heads, how would I do that? And the same for the first position, with tails).
请帮忙 :)