Python实战:年会抽奖程序实现 | 您所在的位置:网站首页 › 序号抽奖小程序 › Python实战:年会抽奖程序实现 |
Python实战:年会抽奖程序实现
王其林: import random #载入随机模块 employees_list=[]#定义员工存储表 for i in range(300): #生成员工编号 employees_name=f"员工{i+1}" employees_list.append(employees_name) print(f"员工列表:{employees_list}") leves_num=[30,6,3]#三二一等 将分别的中奖数 count=(len(leves_num)) print(count) for i in range(count): winer=random.sample(employees_list,leves_num[i]) print(count) print(f"{count-3}等奖中奖者:") for j in winer: print(j,end=" ") employees_list.remove(j) print() Python实战:年会抽奖程序实现王其林: 这个我也写出来了,string模块没有使用到不需要引用 然后你这个是中奖是写了三次,看到有写法是做了两个循环,把中奖数写入数组,以后无论是多少个奖 多少人只需要改一个数字就行 |
CopyRight 2018-2019 实验室设备网 版权所有 |