Last active
August 29, 2015 14:12
-
-
Save agalii/d4e3ed8ce587be0f7214 to your computer and use it in GitHub Desktop.
A python script to test your LaPlace ability
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 sys | |
print ' ' | |
print 'Choose sample size n (default is 100)' | |
n_in = sys.stdin.readline() | |
try: | |
n = int(n_in) | |
except: | |
n = 100 | |
i = 0 | |
penalty_i = 0 | |
penalty_out = ['A random number between 1 and 6 please!', 'This is not a number between 1 and 6!', 'A RANDOM NUMBER BETWEEN 1 AND 6!!! How hard can it be?', 'Stop fooling around!', '*sigh*'] | |
def print_error(): | |
global penalty_i | |
print penalty_out[penalty_i] | |
if penalty_i < len(penalty_out)-1: | |
penalty_i += 1 | |
results = [0,0,0,0,0,0] | |
print ' ' | |
print '#################################' | |
print '# Think first, then type! #' | |
print '#################################' | |
print ' ' | |
while i < n: | |
print 'Choose a truly random number between 1 and 6, please! (run %d of %d)' % (i+1, n) | |
inp = sys.stdin.readline() | |
try: | |
num = int(inp) | |
except: | |
print_error() | |
continue | |
if num < 1 or num > 6: | |
print_error() | |
continue | |
results[num-1] += 1 | |
i += 1 | |
# print results | |
for j in range(0,6): | |
percent = float(results[j]) * 100.0 / float(n) | |
print 'Your personal probability for %d : %.2f %%' % (j+1, percent) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment