# -*- coding: UTF-8 -*-
# @Time :2021/3/18 13:44
# @File :抽奖程序.PY
# @Software: PyCharm
import random
import string
name_list1 = []
surname = ["赵","姑苏","孙","李","白","司马","上官","欧阳","夏侯","诸葛","闻人","东方","百里"]
name = ["承","前","启","厚","德","载","物","天","长","九","浩","起","云","西","秀","蔷","薇","风",
"林","火","山","江","川","湖","海","季","春","花","秋","月","夜","半","灵","起","云","状",
"佩","函","奉","水","扶","东","玖","知","桦","忝","忠","念","政"]
count = 0
count
for i in range(300): # 循环随机产生300个姓名
if name_list1 != '':
name_ran = "".join(random.choice(surname) + random.choice(name) + random.choice(name))
name_list1.append(name_ran)
else:
break
# name_list1 = name_list
# print(name_list)
while count < 3:
count += 1
if count == 1:
print(" 三等奖名单 ".center(40,"-"))
for i in range(30):
award3 = "".join(random.choice(name_list1))
print(f"恭喜下列人员获得 三等奖:{award3}(橡胶人形玩具一个)")
del name_list1[name_list1.index(award3)]
elif count == 2:
print(" 二等奖名单 ".center(40,"-"))
for i in range(6):
award2 = "".join(random.choice(name_list1))
print(f"恭喜下列人员获得 二等奖:{award2}(橡胶气套一盒)")
del name_list1[name_list1.index(award2)]
elif count == 3:
print(" 一等奖名单 ".center(40,"-"))
for i in range(3):
award1 = "".join(random.choice(name_list1))
print(f"恭喜下列人员获得 一等奖:{award1}(日本五日游)")
del name_list1[name_list1.index(award1)]
# print(name_list1)
【初学Python,人总要多学点东西】—— 抽奖小程序
最新推荐文章于 2024-08-14 23:30:40 发布