使用Python买福彩,5个数字,20选5,有没买过

import random,sys,os
num = random.sample(range(1,21),5)
print(num)
f=open("haha.txt","a+")
f.write(str(num)+"\n")
f.close()
person1 = int(input('请输入你要买的数字:'))
person2 = int(input('请输入你要买的数字:'))
person3 = int(input('请输入你要买的数字:'))
person4 = int(input('请输入你要买的数字:'))
person5 = int(input('请输入你要买的数字:'))
if person1 > 20 or person2 > 20 or person3 > 20 or person4 > 20 or person5 > 20:
print("不能输入大于20的数字")
sys.exit()
if person1 == person2 or person1 == person3 or person1 == person4 or person1 == person5 or person2 == person3 or person2 == person4 or person2 == person5 or person3 == person4 or person3 == person5 or person4 == person5:
print("不能购买重复的号码")
sys.exit()
if person2 in num and person3 in num and person4 in num and person5 in num and person1 in num:
print("恭喜你,全中了,奖励320元")
if person1 in num:
if person2 not in num and person3 not in num and person4 not in num and person5 not in num:
print("中了一个,很遗憾没奖励")
if person2 in num and person3 not in num and person4 not in num and person5 not in num:
print("中了两个,很遗憾没奖励")
if person2 in num and person3 in num and person4 not in num and person5 not in num:
print("中三个,很遗憾没奖励")
if person2 in num and person3 in num and person4 in num and person5 not in num:
print("中四个,很遗憾没奖励")
if person2 in num:
if person1 not in num and person3 not in num and person4 not in num and person5 not in num:
print("中了一个,很遗憾没奖励")
if person1 in num and person3 not in num and person4 not in num and person5 not in num:
print("中了两个,很遗憾没奖励")
if person1 in num and person3 in num and person4 not in num and person5 not in num:
print("中三个,很遗憾没奖励")
if person1 in num and person3 in num and person4 in num and person5 not in num:
print("中四个,很遗憾没奖励")
if person3 in num:
if person1 not in num and person2 not in num and person4 not in num and person5 not in num:
print("中了一个,很遗憾没奖励")
if person1 in num and person2 not in num and person4 not in num and person5 not in num:
print("中了两个,很遗憾没奖励")
if person1 in num and person2 in num and person4 not in num and person5 not in num:
print("中三个,很遗憾没奖励")
if person1 in num and person2 in num and person4 in num and person5 not in num:
print("中四个,很遗憾没奖励")
if person4 in num:
if person1 not in num and person2 not in num and person3 not in num and person5 not in num:
print("中了一个,很遗憾没奖励")
if person1 in num and person2 not in num and person3 not in num and person5 not in num:
print("中了两个,很遗憾没奖励")
if person1 in num and person2 in num and person3 not in num and person5 not in num:
print("中三个,很遗憾没奖励")
if person1 in num and person2 in num and person3 in num and person5 not in num:
print("中四个,很遗憾没奖励")
if person5 in num:
if person1 not in num and person2 not in num and person3 not in num and person4 not in num:
print("中了一个,很遗憾没奖励")
if person1 in num and person2 not in num and person3 not in num and person4 not in num:
print("中了两个,很遗憾没奖励")
if person1 in num and person2 in num and person3 not in num and person4 not in num:
print("中三个,很遗憾没奖励")
if person1 in num and person2 in num and person3 in num and person4 not in num:
print("中四个,很遗憾没奖励")
if person1 not in num and person2 not in num and person3 not in num and person4 not in num and person5 not in num:
print("不好意思,一个都没中,要加油哦")
posted on 2019-01-04 17:09  hahamyroot  阅读(469)  评论(0编辑  收藏  举报