来试试你的手气,看多少次能买到头奖的双色球

# -*- coding: utf-8 -*-

import random
import datetime
start = datetime.datetime.now()
flag = True
second_award = 0
third_award = 0
four_award = 0
five_award = 0
six_award = 0
no_award = 0
total_number = 0
#file_reslut = open("reslut.txt","a+",encoding="utf-8")
while flag:
    list_red = []
    list_red_1 = []
    while len(list_red) < 6:#生成随机彩票,6个红球号码
        red = random.randint(1, 33)
        if red not in list_red:
            list_red.append(red)
        else:
            pass
    list_red.sort()#将6个号码排序
    blue = random.randint(1, 16)#随机生成1个蓝球号码

    while len(list_red_1) < 6:#摇号,随机不重复6个红球号码
        red_1 = random.randint(1, 33)
        if red_1 not in list_red_1:
            list_red_1.append(red_1)
        else:
            pass
    list_red_1.sort()#红球号码排序
    blue_1 = random.randint(1, 16)#摇号,一个蓝球号码

    count = 0#判断两组双色球号码有几个红球是一样的
    for i in list_red:
        if i in list_red_1:
            count = count + 1
        else:
            pass
#判断该组双色球号码是否中奖,是几等奖
    if count == 6 and blue == blue_1:
        flag = False
        print("一等奖中奖号码:")
        print(list_red,end=" ")
        print(blue)
        print(list_red_1, end=" ")
        print(blue_1)
    elif count == 5 and blue == blue_1:
        third_award = third_award + 1
    elif count == 4 and blue == blue_1:
        four_award = four_award + 1
    elif count == 3 and blue == blue_1:
        five_award = five_award + 1
    elif count == 2 and blue == blue_1:
        six_award = six_award + 1
    elif count == 1 and blue == blue_1:
        six_award = six_award + 1
    elif count == 0 and blue == blue_1:
        six_award = six_award + 1
    elif count == 6 and blue != blue_1:
        second_award = second_award + 1
    elif count == 5 and blue != blue_1:
        four_award = four_award + 1
    elif count == 4 and blue != blue_1:
        five_award = five_award + 1
    elif count == 3 and blue != blue_1:
        no_award = no_award + 1
    elif count == 2 and blue != blue_1:
        no_award = no_award + 1
    elif count == 1 and blue != blue_1:
        no_award = no_award + 1
    elif count == 0 and blue != blue_1:
        no_award = no_award + 1
    total_number = total_number + 1
print("中二等奖的次数:" + str(second_award))
print("中三等奖的次数:" + str(third_award))
print("中四等奖的次数:" + str(four_award))
print("中五等奖的次数:" + str(five_award))
print("中六等奖的次数:" + str(six_award))
print("没中奖的次数:" + str(no_award))
print("共买彩票次数:" + str(total_number))
total = total_number * 2
print("共花费:" + str(total))
award = 5000000 + second_award*2500000 + third_award*3000 + four_award*200 + five_award*10 + six_award*5
print("共获得奖金:" + str(award))
end = datetime.datetime.now()
print(end - start)
一等奖中奖号码:
[1, 5, 12, 18, 31, 33] 4
[1, 5, 12, 18, 31, 33] 4
中二等奖的次数:11
中三等奖的次数:141
中四等奖的次数:6191
中五等奖的次数:108836
中六等奖的次数:825631
没中奖的次数:13074475
共买彩票次数:14015286
共花费:28030572
共获得奖金:39377715
0:03:56.763208

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值