Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- again = True
- while again:
- import random
- Roll = random.randint(1,6)
- Total = 0
- print ("Main Menu:")
- print ("1) Play 1 Turn of Pig")
- print ("2) Simulate 10000 turns")
- Choice = input("Choice --> ")
- if Choice == '1':
- again = True
- while again:
- Roll = random.randint(1,6)
- if Roll != 1:
- print ("Roll:", Roll)
- Total += Roll
- if Roll == 1:
- print ("Roll:", Roll)
- print ("You rolled a 1. Score this turn: 0")
- again = False
- if Total > 20 or Total == 20:
- print ("Score this turn: ", Total)
- again = False
- elif Choice == '2':
- Counter = 0
- ZeroCount = 0
- RoundTotal = 0
- while again:
- again = True
- while again:
- Roll = random.randint(1,6)
- if Roll != 1:
- Total += Roll
- Counter =+ 1
- if Total >= 20:
- RoundTotal = RoundTotal + Total
- if Roll == 1:
- Counter = Counter + 1
- ZeroCount = ZeroCount + 1
- if Counter >= 10000:
- again = False
- Average = Counter/RoundTotal
- print(ZeroCount)
- print(Average)
- else:
- print ("\nYou were supposed to pick 1 or 2\nGame Over.\n")
- replay = input("Would you like to play again? Y or N ")
- if replay.lower() == 'n':
- again = False
- elif replay.lower() == 'y':
- again = True
Add Comment
Please, Sign In to add comment