This commit is contained in:
2025-08-16 21:02:18 +08:00
parent 3f10677c91
commit 8041fa1438
3 changed files with 53 additions and 0 deletions

35
day7/彩票模拟.py Normal file
View File

@ -0,0 +1,35 @@
import random
randomlist = []
def add():
randomlist.append(random.randint(1000, 9999))
return randomlist
number = int(input("初始量:"))
if number <= 0:
print("初始量须>=1")
number = int(input("初始量:"))
for i in range(1, number + 1):
if i <= number:
add()
while True:
randomlist.append(int(input("加入4位竞猜号码")))
a = int(input("是否继续加入1是2否"))
if a == 1:
continue
else:
break
randomlist.sort()
print(randomlist)
choice = int(input("请确认彩票号码"))
if choice not in randomlist:
print("不在范围内")
choice = int(input("请确认彩票号码"))
correct = random.choice(randomlist)
if choice == correct:
print("")
else:
print("手慢无")