Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. import random
  2.  
  3. wins=0
  4. attempts=100000
  5. for case in range(0, attempts):
  6.     score=0
  7.     for flip in range(0, 100):
  8.         result=random.uniform(-1,1) #tails, heads
  9.         if (result<0):
  10.             result=-1
  11.         else:
  12.             result=1
  13.  
  14.         if (score<0): #"doubles" the coin's worth (adds result twice)
  15.             score=score+result
  16.         score=score+result
  17.     if (score>0):
  18.         wins+=1;
  19. print(wins)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement