Advertisement
Sev_Seven

dice roll 01

Sep 17th, 2021 (edited)
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. # dice rolling app
  2. # pick the die you want to roll
  3. # Random number of rolls based on the sides of the die, this is the roll number
  4. # 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
  5. # this will repeat based on the total number of sides
  6. # then display the result
  7.  
  8. import random
  9.  
  10. #dieResult = random.randrange(1,6)
  11. # D6 function
  12. def sixSideDie():
  13. global dieResult
  14. dieRoll = 0
  15. dieResult = random.randrange(1, 7)
  16. while dieRoll < 1:
  17.  
  18. if dieResult == 1:
  19. side = [2, 3, 4, 5]
  20. random.shuffle(side)
  21. dieResult = random.choice(side)
  22. if dieResult == 2:
  23. side = [1, 3, 4, 6]
  24. dieResult = random.choice(side)
  25. if dieResult == 3:
  26. side = [1, 2, 5, 6]
  27. random.shuffle(side)
  28. dieResult = random.choice(side)
  29. if dieResult == 4:
  30. side = [1, 2, 5, 6]
  31. random.shuffle(side)
  32. dieResult = random.choice(side)
  33. if dieResult == 5:
  34. side = [1, 3, 4, 6]
  35. random.shuffle(side)
  36. dieResult = random.choice(side)
  37. if dieResult == 6:
  38. side = [2, 3, 4, 5]
  39. random.shuffle(side)
  40. dieResult = random.choice(side)
  41. dieRoll += 1
  42.  
  43.  
  44. def testerDie():
  45. global testerList
  46. dRoll = 0
  47. testerList = []
  48. while dRoll < 1000:
  49.  
  50. #dieResult = random.randrange(1, 7)
  51. sixSideDie()
  52. testerList.append(dieResult)
  53. dRoll += 1
  54.  
  55. testerDie()
  56.  
  57. #print(testerList)
  58. print(testerList.count(1))
  59. print(testerList.count(2))
  60. print(testerList.count(3))
  61. print(testerList.count(4))
  62. print(testerList.count(5))
  63. print(testerList.count(6))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement