-
-
Save xcellerator/6ed99ebbe75f6804397f5d7cd9c455e1 to your computer and use it in GitHub Desktop.
Coin flip loop to test RNG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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