Final answer:
To generate lottery numbers, you can write a Python function using the random.randint() function, ensuring no duplicates by checking each generated number against the list. The numbers are then sorted and returned. Customers' and winning numbers are compared to determine the prize.
Step-by-step explanation:
Random Lottery Number Generator Function
To create a function in Python that generates a list of unique lottery numbers, you can use the random.randint() function from the random module. This function allows us to generate a random integer within a specified range.
The function will accept three parameters: start value, end value, and how many numbers to choose. It will return a sorted list of these numbers, ensuring no duplicates are present.
Step-by-Step Guide:
1. Import the random module.
2. Define the function with the appropriate parameters.
3. Within the function, initiate an empty list for the lottery numbers.
4. Use a loop to generate random numbers until the list contains the specified amount of unique numbers.
5. Within the loop, check if the generated number is already in the list.
6. If not, append it to the list; if it is, continue the loop without appending.
7. After the list is complete, sort it.
8. Return the sorted list of lottery numbers.
When using this function, you'll generate two lists: one for the winning numbers and one for the customer's numbers. Afterward, compare these lists to find out how many numbers the customer got right and whether they win a prize if they match four or more numbers.