import random
list_more = list(range(1,101))
#一等奖 10%
list_1 = random.sample(list_more,10)
#二等奖 20%
list_2 = random.sample(list(set(list_more)-set(list_1)),20)
#三等奖 30%
list_3 = random.sample(list(set(list_more)-set(list_1)-set(list_2)),30)
#四等奖 40%
list_4 = random.sample(list(set(list_more)-set(list_1)-set(list_2)-set(list_3)),40)
print list_1,len(list_1)
print list_2,len(list_2)
print list_3,len(list_3)
print list_4,len(list_4)
a = raw_input("开始抽奖:(Y/N)" )
if a.lower() == "y":
x = random.randint(1,100)
print x
if x in list_1:
print ("恭喜一等奖")
elif x in list_2:
print ("恭喜二等奖")
elif x in list_3:
print ("恭喜三等奖")
else:
print ("恭喜四等奖")
这样保证每一次进行抽奖前,奖池中对应的个的中奖池号码是随机生成的,提高了逻辑的严谨性