Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # dice rolling app
- # pick the die you want to roll
- # Random number of rolls based on the sides of the die, this is the roll number
- # that roll number will be the first number it starts on and will randomlly pick a number the it will be next to on a die
- # this will repeat based on the total number of sides
- # then display the result
- import random
- #dieResult = random.randrange(1,6)
- # D6 function
- def sixSideDie():
- global dieResult
- dieRoll = 0
- dieResult = random.randrange(1, 7)
- while dieRoll < 1:
- if dieResult == 1:
- side = [2, 3, 4, 5]
- random.shuffle(side)
- dieResult = random.choice(side)
- if dieResult == 2:
- side = [1, 3, 4, 6]
- dieResult = random.choice(side)
- if dieResult == 3:
- side = [1, 2, 5, 6]
- random.shuffle(side)
- dieResult = random.choice(side)
- if dieResult == 4:
- side = [1, 2, 5, 6]
- random.shuffle(side)
- dieResult = random.choice(side)
- if dieResult == 5:
- side = [1, 3, 4, 6]
- random.shuffle(side)
- dieResult = random.choice(side)
- if dieResult == 6:
- side = [2, 3, 4, 5]
- random.shuffle(side)
- dieResult = random.choice(side)
- dieRoll += 1
- def testerDie():
- global testerList
- dRoll = 0
- testerList = []
- while dRoll < 1000:
- #dieResult = random.randrange(1, 7)
- sixSideDie()
- testerList.append(dieResult)
- dRoll += 1
- testerDie()
- #print(testerList)
- print(testerList.count(1))
- print(testerList.count(2))
- print(testerList.count(3))
- print(testerList.count(4))
- print(testerList.count(5))
- print(testerList.count(6))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement