I need to simulate the flipping of a coin, with heads = 0
and tails = 1
. And each time a random number is generated between 1 and 0, heads or tails needs to be incremented and updated in the array. Below is the code I have:
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).
Please help :)
Wouldn't that do the trick ?
import numpy, random
flips = numpy.array([0,0])
for i in range(10):
flips[random.randint(0,1)] += 1