-
Notifications
You must be signed in to change notification settings - Fork 0
/
martingale_betting.py
49 lines (40 loc) · 1.23 KB
/
martingale_betting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 26 13:19:39 2019
@author: gajdulj
"""
import random as rn
def bet():
cash = 1000
round_count = 0
stake = 3
for i in range (100):
outcome = rn.randint(0,1) #50% chance gamble
print ("Round number:",round_count)
print ("Current cash: £{}".format(cash))
print ("Current stake: £{}".format(stake))
if outcome == 0:
print ("Round Lost")
cash = (cash - stake)
if cash > 0:
stake = stake * 2
print ("Current cash: £{}".format(cash))
print ("Betting £{}".format(stake))
round_count +=1
print("\n")
outcome = rn.randint(0,1)
else:
print ("Game over")
print("\n")
break
elif outcome == 1:
print ("Round won")
cash = (cash + stake)
stake = 3
print ("Current cash: £{}".format(cash))
print ("Betting £{}".format(stake))
round_count +=1
print("\n")
print ("Survived ",round_count, " rounds")
bet()