-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPowerBall.py
More file actions
50 lines (39 loc) · 1.18 KB
/
Copy pathPowerBall.py
File metadata and controls
50 lines (39 loc) · 1.18 KB
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
# Power Ball Lottery Code
#This program tells whether you have won the lottery or not
from random import randrange
#This module generates the lucky no. for the lottery winner.
#The lucky no. has 5 distinct random no.s between [1,60) clubbed together and a powerball no. between [1,36)
def lottery_no():
lucky_no = []
n = 1
while(n < 6):
flag = 1
random_no = randrange(1,60)
for number in lucky_no:
if random_no == number:
flag = 0
if flag == 1:
lucky_no.append(random_no)
n += 1
powerball_no = randrange(1,36)
flag = 1
for no in lucky_no:
if no == powerball_no:
flag = 0
lucky_no.append(powerball_no)
return lucky_no
# Take the input of ticket no. of the user
lottery_ticket_no = []
n=1
while (n < 7):
lottery_ticket_no.append(int(input()))
n += 1
# Checking whether user wins
lucky_no = lottery_no()
print("The lottery no. is:", lucky_no)
if(lucky_no == lottery_ticket_no):
print("You win the jackpot")
elif(lucky_no[len(lucky_no)-1] == lottery_ticket_no[len(lottery_ticket_no)-1]):
print("You win the power ball no.")
else:
print("You lost")