Skip to content

anonymous /diceAverage.py
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.