Write down a python code to generate 3 sets of lottery tickets randomly from the pool of 300
tickets with an equal probability distribution, and keep in mind that if a set of the number already
selected in the first-month lottery, the same number is not allowed to repeat.
import random
tickets=[[0] * 12 for i in range(3)]
print("3 sets of lottery tickets (3 * 12 month):")
for i in range(3):
for j in range(12):
ticket = random.randint(1, 300)
while ticket in tickets[i]:
ticket = random.randint(1, 300)
tickets[i][j] = ticket
print(f"1 set: {tickets[0]}\n2 set: {tickets[1]}\n3 set: {tickets[2]}")
Comments
Leave a comment