Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Python program and make sure the program run properly Write a program to

ID: 3886808 • Letter: W

Question

Write a Python program and make sure the program run properly

Write a program to help determine the likelihood of winning the lottery. People pick six integers from 1 to 59, inclusive. Six lottery numbers are selected at random from the same range. If a person's six numbers match the lottery-selected numbers, the person wins a large cash prize. If the user matches any five of the six lottery-selected numbers, the person wins a smaller but not insignificant prize. The basic program must do the following: 1) Have the user select six numbers. These numbers must be in the correct range and none of the numbers must not repeat (i.e. the user may not select the same number twice) 2) Randomly select six numbers. The same restrictions for number selection apply. 3) Sort the numbers entered by the user and by the lottery system so that the output is attractive 4) Assume the user plays approximately 9000 times - about three times per week for his or her lifetime of legal playing, about 57 years and that a lottery ticket costs $1.00 each. 5) Output the amount of money the user wins or loses. A sample of the basic program is below: Enter six numbers for the lottery: 17 38 14 44 7 50 You selected: 7, 14, 17, 38, 44, 50 On week 6359, numbers are: 7,14, 38,44, 50, 56 You're a MILLION DOLLAR winner!!! Your total return is $980925.00

Explanation / Answer

from random import randint

def randlist():

ans = []

for i in range(6):

ans.append(randint(1,59))

#print(ans)

return ans

def comparelist(x, y):

z = list(set(x).union(set(y)))

if len(z) is len(x):

return True

return False

l = input("Enter six numbers for the lottery:")

l = l.split()

try:

for a in range(0,len(l)):

l[a] = int(l[a])

except:

print("Enter integer values")

l.sort()

l = list(set(l))

if(len(l)!=6):

print("Invalid input")

exit()

for a in range(6):

if(l[a]<1 and l[a]>59):

print("Invalid input")

exit()

for i in range(1,9001):

rlist1 = randlist()

rlist1.sort()

if comparelist(l,rlist1):

cost = (i-1)*3+1

print("On week "+i+", numbers are:"+','.join(rlist1))

print("You are a MILLION DOLLAR winner!!")

print("Your total return is $"+str(1000000-cost))

print("Total amount spent is $"+str(cost))

exit()

rlist2 = randlist()

rlist2.sort()

if comparelist(l,rlist2):

cost = (i-1)*3+2

print("On week "+i+", numbers are:"+','.join(rlist2))

print("You are a MILLION DOLLAR winner!!")

print("Your total return is $"+str(1000000-cost))

print("Total amount spent is $"+str(cost))

exit()

rlist3 = randlist()

rlist3.sort()

if comparelist(l,rlist3):

cost = (i-1)*3+3

print("On week "+i+", numbers are:"+','.join(rlist3))

print("You are a MILLION DOLLAR winner!!")

print("Your total return is $"+str(1000000-cost))

print("Total amount spent is $"+str(cost))

exit()

cost = 9000*3

print("Total amount spent is $"+str(cost))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote