Python双色球开奖

Python双色球开奖,第1张

import random

red,blue,user_red = [],[],[]

user_blue = None

shuzi = 0

# 用户输入红球

while len(user_red) != 6 :

    r = int(input(f"请输入第{len(user_red)+1}个红球数字(1-33):"))

    if r not in user_red and True if r >= 1 and r <= 33 else False:

        user_red.append(r)

    elif True if r < 1 or r > 33 else False:

        print("红球输入超出范围!")

    else:

        print("红球输入重复!")

# 系统随机红球

while len(red) != 6 :

    hq = random.randint(1,33)

    if hq not in red :

        red.append(hq)

# 用户输入蓝球

while user_blue == None :

    lan = int(input("请输入蓝球数字(1-16):"))

    if True if lan >= 1 and lan <= 16 else False:

        user_blue = lan

        # 系统随机蓝球

        blue = random.randint(1,16)

    else:

        print("蓝球输入超出范围!")

# 取出red随机值和输入user_red的值依次对比

for r in red:

    for ur in user_red:

        if r == ur:

            shuzi += 1

# 满足条件获奖

if blue == user_blue and shuzi == 6:

    print("#"*50)

    print("恭喜你中了一等奖!")

    print("#"*50)

elif shuzi == 6 and blue != user_blue:

    print("#"*50)

    print("恭喜你中了二等奖!")

    print("#"*50)

elif shuzi == 5 and blue == user_blue:

    print("#"*50)

    print("恭喜你中了三等奖!")

    print("#"*50)

elif shuzi == 5 and blue != user_blue or shuzi == 4 and blue == user_blue:

    print("#"*50)

    print("恭喜你中了四等奖!")

    print("#"*50)

elif shuzi == 4 and blue != user_blue or shuzi == 3 and blue == user_blue:

    print("#"*50)

    print("恭喜你中了五等奖!")

    print("#"*50)

elif blue == user_blue or shuzi == 1 and blue == user_blue or shuzi == 2 and blue == user_blue:

    print("#"*50)

    print("恭喜你中了六等奖!")

    print("#"*50)

else:

    print("#"*50)

    print("\t很遗憾你没中奖!")

    print("#"*50)

# 公布结果

print(f"开出得红球分别为:{red}")

print(f"开出得蓝球为:{blue}")

print(f"你选择得红球分别为:{user_red}")

print(f"你选择得蓝球为:{user_blue}")

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/756756.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-30
下一篇 2022-04-30

发表评论

登录后才能评论

评论列表(0条)

保存