MAKE sure the program ru properlu and Also PLEASE include the output of the prog
ID: 3888922 • Letter: M
Question
MAKE sure the program ru properlu and Also PLEASE include the output of the program:
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 Since not every user will win, the basic program must also output a message saying how much the user spends (loses), where appropriate The advanced 1) Assume 100,000 players, each with a set of lottery numbers selected at random as above and each paying $1.00 per game, three times per week. For each draw (each new game when the lottery numbers are selected), a player has a 50% chance of generating new numbers or keeping their existing numbers from a previous game 2) Generate lottery numbers as above for 3,600 games 3) Output the amount of money the lottery system makes or loses 4) Matching 6 number wins 100 million, matching 5 number wins 5 million program must do the followingExplanation / Answer
import random
menu_check = True
# 'checker', compares userNums and winningNums to see if they have won or lost
def checker(userNums, winningNums):
if userNums == winningNums:
print (" Congratulations! You Win $100! ")
print ("Your numbers: ", userNums)
print ("The winning lottery numbers are: ", winningNums, " ")
else:
print (" Sorry, you lose... ")
print ("Your numbers: ", userNums)
print ("The winning lottery numbers are: ", winningNums, " ")
# 'getUserNums', gets user numbers and puts into a sorted list
def getUserNums():
userNums = []
for x in range(3):
nums = int(input("Pick a number 0 through 9: "))
if 0 <= nums <= 9:
userNums.append(nums)
else:
input("Error! Invalid input. Press any key to continue...")
nums = int(input("Pick a number 0 through 9: "))
userNums.append(nums)
return sorted(userNums)
# 'getWinningNums', creates a sorted list with random nums ranging from 0-9 with a range of 3 values
def getWinningNums():
return sorted(random.sample(range(0,10), 3))
# 'menu', creates the main menu to choose game or exit program
def menu():
print (30 * "-", "LOTTERY MENU", 30 * "-")
print ("1. [Play Pick-3]")
print ("2. Exit")
print (75 * "-")
# 'main', calls the other functions
def main():
userNums = getUserNums()
winningNums = getWinningNums()
checker(userNums, winningNums)
#
while menu_check:
menu()
choice = input(" Enter your choice[1-2]: ")
if choice == '1':
print (23 * "-")
print ("[Play Pick-3] selected!")
print (23 * "-")
menu_check = False
main()
elif choice == '2':
print (" Thanks for playing! ")
menu_check = False
else:
input("Error! Invalid input. Press any key to continue... ")
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.