Instantly share code, notes, and snippets.

# anonymous/diceAverage.py Created Jul 29, 2012

Made a program that rolls 100 pairs of dice and counts each result. BAD CODE
 import random oneCounter = 0 twoCounter = 0 threeCounter=0 fourCounter=0 fiveCounter=0 sixCounter=0 sevenCounter = 0 eightCounter=0 nineCounter=0 tenCounter=0 elevenCounter=0 twelveCounter=0 x=1 allDice = 0 while x <=100: dice1 = random.randint(1,6) dice2 = random.randint(1,6) currentDice = dice1 + dice2 allDice = currentDice + allDice x += 1 print dice1,dice2 if currentDice==1: oneCounter+=1 if currentDice==2: twoCounter==1 if currentDice==3: threeCounter+=1 if currentDice==4: fourCounter+=1 if currentDice==5: fiveCounter+=1 if currentDice==6: sixCounter+=1 if currentDice==7: sevenCounter += 1 if currentDice==8: eightCounter+=1 if currentDice==9: nineCounter+=1 if currentDice==10: tenCounter+=1 if currentDice==11: elevenCounter+=1 if currentDice==12: twelveCounter+=1 print 'average is:', allDice/x print 'one:', oneCounter print 'two:', twoCounter print 'three:', threeCounter print 'four:', fourCounter print 'five:', fiveCounter print 'six:', sixCounter print 'seven', sevenCounter print 'eight:', eightCounter print 'nine:', nineCounter print 'ten:', tenCounter print 'eleven:', elevenCounter print 'twevle:', twelveCounter