Python双色球开奖

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}")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值