public
anonymous / diceAverage.py
Created

Made a program that rolls 100 pairs of dice and counts each result. BAD CODE

  • Download Gist
diceAverage.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.