Skip to content

Instantly share code, notes, and snippets.

@xcellerator
Created September 10, 2020 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xcellerator/6ed99ebbe75f6804397f5d7cd9c455e1 to your computer and use it in GitHub Desktop.
Save xcellerator/6ed99ebbe75f6804397f5d7cd9c455e1 to your computer and use it in GitHub Desktop.
Coin flip loop to test RNG
#!/usr/bin/python3
import random
import time
SAMPLE_SIZE = 1000
while 1:
headcount = 0
coinflips = []
for i in range(SAMPLE_SIZE):
newflip = random.randint(0,1)
if ( newflip == 0 ):
headcount += 1
coinflips.append(newflip)
print("Heads: " + str(headcount))
print("Tails: " + str(SAMPLE_SIZE - headcount))
print("")
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment