-
-
Save anonymous/7822057 to your computer and use it in GitHub Desktop.
Experiment on random.randrange
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
import random | |
i = 0 | |
ratio = {} | |
rounds = 10000000 | |
while i < rounds: | |
r = random.randrange(1, 11) | |
if r in ratio: | |
ratio[r] = ratio[r] + 1 | |
else: | |
ratio[r] = 1 | |
i = i + 1 | |
for item in ratio: | |
print (str(item) + ': ' + str((ratio[item] / float(rounds)) * 100) + '%') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment