Answer to Question #320215 in Python for ali

Question #320215

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.


1
Expert's answer
2022-03-29T07:41:32-0400
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]}")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS