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
while flag:
list_red = []
list_red_1 = []
while len(list_red) < 6:
red = random.randint(1, 33)
if red not in list_red:
list_red.append(red)
else:
pass
list_red.sort()
blue = random.randint(1, 16)
while len(list_red_1) < 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