-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloyto.py
78 lines (42 loc) · 1.42 KB
/
loyto.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import math # Importing math functions
import random # Importing random functions such as randint()
import os
def unique_pick(n): # Makes sure that unique numbers are picked.
pick = random.randint(1, 60)
if pick in n:
return unique_pick(n)
else:
return pick
def lottery(): # This randomly generates the numbers you would pick.
my_numbers = []
i = 0
while i < 5:
pick = unique_pick(my_numbers)
my_numbers.append(pick)
i += 1
return my_numbers
def generate_winning_picks(): # This generates the winning numbers to the lottery.
winning_picks = []
i = 0
while i < 5:
winning_pick = unique_pick(winning_picks)
winning_picks.append(winning_pick)
i += 1
return winning_picks
def game():
my_picks = lottery()
winning_nums = generate_winning_picks()
wins = 0
for i in winning_nums:
if i in my_picks:
wins+=1
return wins
def main():
total = 10000000
list_of_wins = []
for i in range(0,total):
list_of_wins.append(game())
for i in range(0, 6):
num_of_win = list_of_wins.count(i)
print("Winning", i, "Ball:", num_of_win, "-", (num_of_win/total)*100)
main()