Skip to content

Commit 5ade7b4

Browse files
committed
resubmitting lab05
1 parent 6455b39 commit 5ade7b4

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

code/jonpan/lab05.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
ticket_cost = (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+
payoff = balance + ticket_cost
36+
37+
print(payoff)

0 commit comments

Comments
 (0)