Skip to content

Instantly share code, notes, and snippets.

@parsons-Jsr
Created November 9, 2012 02:21
Show Gist options
  • Save parsons-Jsr/4043321 to your computer and use it in GitHub Desktop.
Save parsons-Jsr/4043321 to your computer and use it in GitHub Desktop.
Python Basic Decision Maker using Random Module
import random
yes = 0
no = 0
choice = list(["yes", "no"])
accuracy = 1
print "------------------------------"
print " Jamie's Decision Maker"
print "------------------------------"
print " "
item_name = raw_input("What is the name of your item?:\n\n")
print "\nHow accurate do you want the test?:"
accuracy = float(raw_input("1 = low\n2 = med\n3 = high\n4 = extreme\n5 = custom\n\n"))
if accuracy == 1:
repeat = 1000
if accuracy == 2:
repeat = 10000
if accuracy == 3:
repeat = 100000
if accuracy == 4:
repeat = 1000000
if accuracy == 5:
repeat = int(raw_input("\nEnter desired amount of repitions:\n\n"))
for i in range (repeat):
if random.choice(choice) == "yes":
yes += 1
else:
no += 1
if yes > no:
print "\n------------------------------"
print " Result"
print "------------------------------"
print "YES go buy a %s! :)" % item_name
else:
print "\n------------------------------"
print " Result"
print "------------------------------"
print "NO! don't buy a %s! :(" % item_name
perc = round((float(yes)/float(repeat) * 100),3)
print "\n------------------------------"
print " Statistics"
print "------------------------------"
print "Repitions: %8i" % repeat
print "yes:no: %10s:%i" % (yes,no)
print "%% Yes: %12s%%" % perc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment