Skip to content

Commit 2be2898

Browse files
Merge pull request #80 from PdxCodeGuild/zach-lab05-pick6
Finished lab 5.
2 parents 3eedb2d + 52a966a commit 2be2898

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

code/zach/lab05-pick6.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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()

0 commit comments

Comments
 (0)