python代码
import random
#抽奖系统
#等级
dj = ["一","二","三"]
#奖品
jp = ["three apple",'two apple',"one apple"]
#定义一等奖的随机数
a = random.randint(10,13)
#定义二等奖的随机数
b = random.randint(20, 30)
#定义三等奖的随机数
c = random.randint(100, 130)
print("随机数:",a,b,c)#查看随机数
#循环初始数
n=1
#循环3次
while n<= 3:
chou = int(input("请输入抽签编号(1-200):"))
if chou == a:
print("恭喜你,抽中{}等奖,奖品是:{}".format(dj[0],jp[0]))
elif chou == b:
print("恭喜你,抽中{}等奖,奖品是:{}".format(dj[1],jp[1]))
elif chou == c:
print("恭喜你,抽中{}等奖,奖品是:{}".format(dj[2],jp[2]))
else:
print("谢谢惠顾")
n+= 1
测试结果
随机数: 11 23 111
请输入抽签编号(1-200):1
谢谢惠顾
请输入抽签编号(1-200):23
恭喜你,抽中二等奖,奖品是:two apple
请输入抽签编号(1-200):155
谢谢惠顾