Title: A company has 300 employees and holds an annual lucky draw. The prizes are as follows: first prize 3: second prize of a 5-day trip to Thailand 6: third prize of aN Iphone 30: A box of small air purifier Rule: 1. Draw three times altogether, draw the third prize for the first time, draw the second prize for the second time, draw the first prize for the third time. 2. Each employee shall win the prize only once. 1. Generate a list of employees and use the random module to randomly select values from the list. 2. Delete the winners from the employee list immediately after taking the value to prevent them from winning again. Python code:

PS: If you need Python learning materials, please click on the link below to obtain them

Free Python learning materials and group communication solutions click to join

Import random staff_list = [] for I in range(0,300): Staff_list.append (f' staff {I}') lottery_levels = [30,6,3] count = 0 while count < 3: choice = input(f' start drawing {3-count} awards... :') winners = random.sample(staff_list,lottery_levels[count]) print(winners) for p in winners: Staff_list.remove (p) # remove winner count += 1Copy the code

Effect after operation:

! [](https://p1.pstatp.com/origin/pgc-image/1a3cde419d1649cdac335f2f71323e24)

Isn’t that easy? Did you learn it?