Skip to content

Instantly share code, notes, and snippets.

@s16h
Last active August 29, 2015 14:01
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 s16h/b4c2bc791880b61418b2 to your computer and use it in GitHub Desktop.
Save s16h/b4c2bc791880b61418b2 to your computer and use it in GitHub Desktop.
import random
def dice_roll():
return random.randint(1,6)
count = int(input("Enter the number of rolls: "))
number_of_double_dice = 0
results = [0 for x in range(13)]
for i in range(0,count):
first = dice_roll()
second = dice_roll()
sum = first + second
if(first == second):
number_of_double_dice = number_of_double_dice + 1
results[sum] = results[sum] + 1
for x in range (2,13):
print("{0:d} - {1:d} {2:0.4f}%".format(x, results[x], fesults[x])/ount*100))
print("Doubles- {0:d}-{1:0.6f}%".format(number_of_double_dice, number_of_double_dice/count*100))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment