1

と を使用して、コインの裏返しをシミュレートする必要が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).

助けてください :)

4

2 に答える 2