【初学Python,人总要多学点东西】—— 抽奖小程序

# -*- 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)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值