Guest User

Untitled

a guest
Nov 16th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. again = True
  2. while again:
  3.  
  4. import random
  5. Roll = random.randint(1,6)
  6. Total = 0
  7.  
  8. print ("Main Menu:")
  9. print ("1) Play 1 Turn of Pig")
  10. print ("2) Simulate 10000 turns")
  11.  
  12. Choice = input("Choice --> ")
  13.  
  14. if Choice == '1':
  15. again = True
  16. while again:
  17. Roll = random.randint(1,6)
  18. if Roll != 1:
  19. print ("Roll:", Roll)
  20. Total += Roll
  21. if Roll == 1:
  22. print ("Roll:", Roll)
  23. print ("You rolled a 1. Score this turn: 0")
  24. again = False
  25. if Total > 20 or Total == 20:
  26. print ("Score this turn: ", Total)
  27. again = False
  28.  
  29. elif Choice == '2':
  30. Counter = 0
  31. ZeroCount = 0
  32. RoundTotal = 0
  33. while again:
  34. again = True
  35. while again:
  36. Roll = random.randint(1,6)
  37. if Roll != 1:
  38. Total += Roll
  39. Counter =+ 1
  40. if Total >= 20:
  41. RoundTotal = RoundTotal + Total
  42. if Roll == 1:
  43. Counter = Counter + 1
  44. ZeroCount = ZeroCount + 1
  45. if Counter >= 10000:
  46. again = False
  47. Average = Counter/RoundTotal
  48. print(ZeroCount)
  49. print(Average)
  50.  
  51.  
  52.  
  53.  
  54. else:
  55. print ("\nYou were supposed to pick 1 or 2\nGame Over.\n")
  56.  
  57. replay = input("Would you like to play again? Y or N ")
  58. if replay.lower() == 'n':
  59. again = False
  60. elif replay.lower() == 'y':
  61. again = True
Add Comment
Please, Sign In to add comment