File tree Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Original file line number Diff line number Diff line change
1
+ import random
2
+
3
+ def pick6 ():
4
+ index = 0
5
+ winning = []
6
+ ticket = []
7
+
8
+ while index < 6 :
9
+ winning .append (random .choice (range (1 , 100 )))
10
+ ticket .append (random .choice (range (1 , 100 )))
11
+ index += 1
12
+
13
+ return winning , ticket
14
+
15
+ def num_matches (winning , ticket ):
16
+ index = 0
17
+ matches = 0
18
+
19
+ while index < 6 :
20
+ if winning [index ] == ticket [index ]:
21
+ matches += 1
22
+
23
+ index += 1
24
+
25
+ return matches
26
+
27
+ def main ():
28
+ index = 0
29
+ balance = 0
30
+ earnings = 0
31
+ expenses = 0
32
+
33
+ while index < 100000 :
34
+ winning , ticket = pick6 ()
35
+ matches = num_matches (winning , ticket )
36
+
37
+ if matches == 0 :
38
+ earnings += 0
39
+ elif matches == 1 :
40
+ earnings += 4
41
+ elif matches == 2 :
42
+ earnings += 7
43
+ elif matches == 3 :
44
+ earnings += 100
45
+ elif matches == 4 :
46
+ earnings += 50000
47
+ elif matches == 5 :
48
+ earnings += 1000000
49
+ elif matches == 6 :
50
+ earnings += 25000000
51
+
52
+ expenses -= 2
53
+ index += 1
54
+
55
+ balance = earnings + expenses
56
+ ROI = (earnings + expenses ) / expenses
57
+
58
+ return print (f'Final Balance: { balance } ' ), print (f'ROI: { ROI } ' )
59
+
60
+ main ()
You can’t perform that action at this time.
0 commit comments