Question: PYTHON ONLY URGENT Part 1 : The lottery is a game of chance that asks a player to select a certain number of non-repeating positive
PYTHON ONLY URGENT
Part 1: The lottery is a game of chance that asks a player to select a certain number of non-repeating positive integers within a specific range. The user's numbers are then compared against a randomized set of numbers and if they match the user wins a large prize.
For example, let's assume we were playing a "pick 3" lottery game the user would pick 3 values within a range (say, 1 to 50). A valid lottery pick for this game would be [1, 5, 7] or [12, 48, 50]. No two numbers can repeat (i.e. [1,1,3] is invalid) and numbers must be within the range specified. Numbers are always ordered in ascending order.
Write a FUNCTION called "lottery" which generates a set of random lottery numbers. Your function should accept three arguments the number of values to generate, the lowest possible value and the highest possible value. It should RETURN a LIST of the desired random numbers in ascending order. No duplicate values are allowed. No user input is required for this part. Here is a sample running of this function:
n1 = lottery(3, 1, 50) print(n1) # [2, 25, 41]
Part 2: Next, use this function to write a program to see how long it would take for a player to win using a specific set of numbers. You will need to ask the user for a series of 3 numbers to do this. Ensure that the user's numbers are between 1 and 50, and that they do not supply duplicate numbers. Here are a few sample runnings of the program (user input is underlined):
------ Run #1 -----
Enter a number: 1
Enter a number: 7
Enter a number: 5
Your numbers are: [1, 5, 7]
It took 38484 lottery drawings for you to win!
------ Run #2 -----
Enter a number: 30
Enter a number: 12
Enter a number: 3
Your numbers are: [3, 12, 30]
It took 49408 lottery drawings for you to win!
------ Run #3 -----
Enter a number: -10
Invalid, try again
Enter a number: 55
Invalid, try again
Enter a number: 1
Enter a number: 1
Invalid, try again
Enter a number: 5
Enter a number: 9
Your numbers are: [1, 5, 9]
It took 4073 lottery drawings for you to win!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
