Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- wins=0
- attempts=100000
- for case in range(0, attempts):
- score=0
- for flip in range(0, 100):
- result=random.uniform(-1,1) #tails, heads
- if (result<0):
- result=-1
- else:
- result=1
- if (score<0): #"doubles" the coin's worth (adds result twice)
- score=score+result
- score=score+result
- if (score>0):
- wins+=1;
- print(wins)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement