This is homework and following may not apply.
To simulate coin flipping one can just:
To simulate coin flipping one can just:
>>> random.choices(['heads', 'tails'], k=5) ['tails', 'tails', 'heads', 'tails', 'tails']To verify that it its evenly distributed:
>>> random.choices(['heads', 'tails'], k=1000).count('heads') 501One can add weights or cumulative weights ('biased coin'):
>>> random.choices(['heads', 'tails'], cum_weights=[0.70, 1.00], k=1000).count('heads') 703Result can be printed out using unpacking and sep:
>>> print(*random.choices(['heads', 'tails'], k=5), sep='\n') tails heads heads tails heads
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.