Skip to content

Commit 49ebaf4

Browse files
Merge pull request #84 from PdxCodeGuild/jonpan-newlab05-pick6
jonpan resubmitting lab05 on a new branch
2 parents 0560c18 + 8e12fe3 commit 49ebaf4

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

code/jonpan/lab05.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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"\nEarnings: {earnings} ")
41+
print(f"\nExpenses: {expenses} ")
42+
print(f"\nROI: {ROI:.0%} ")

0 commit comments

Comments
 (0)