File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ import random
2
+
3
+ def matches_count (winning_ticket , purchase_ticket ):
4
+ matches = 0
5
+ for x in range (6 ):
6
+ if winning_ticket [x ] == purchase_ticket [x ]:
7
+ matches += 1
8
+ return matches
9
+
10
+ def pick_number (x = 6 ):
11
+ return random .sample (range (1 , 99 ), x )
12
+
13
+ balance = 0
14
+ loops = 100000
15
+ expenses = (loops * - 2 )
16
+ winning_ticket = pick_number ()
17
+
18
+ for x in range (loops ):
19
+ purchase_ticket = pick_number ()
20
+ match_counter = matches_count (winning_ticket , purchase_ticket )
21
+
22
+ if match_counter == 1 :
23
+ balance += 4
24
+ elif match_counter == 2 :
25
+ balance += 7
26
+ elif match_counter == 3 :
27
+ balance += 100
28
+ elif match_counter == 4 :
29
+ balance += 50000
30
+ elif match_counter == 5 :
31
+ balance += 1000000
32
+ elif match_counter == 6 :
33
+ balance += 25000000
34
+
35
+ earnings = balance + expenses
36
+ ROI = (earnings - expenses ) / earnings
37
+ # ROI_pct = "{. 0%}".format(ROI)
38
+ # print(ROI_pct)
39
+
40
+ print (f"\n Earnings: { earnings } " )
41
+ print (f"\n Expenses: { expenses } " )
42
+ print (f"\n ROI: { ROI :.0%} " )
You can’t perform that action at this time.
0 commit comments