Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def main():
- winsA = 0
- winsB = 0
- for x in range(1000):
- scoreA = 7
- scoreB = 1
- while (scoreA < 11 and scoreB < 11) or abs(scoreA-scoreB)<2:
- x = random.random()
- if x>.5:
- scoreA += 1
- else:
- scoreB += 1
- print(f'{scoreA}-{scoreB}')
- if scoreA > scoreB:
- winsA += 1
- else:
- winsB += 1
- winPct = round(winsA/(winsA+winsB)*100)
- print(f'With a 7-1 lead, player A wins {winPct}% of the simulations.')
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement