Python simply realizes the double color ball function

Python simply realizes the double color ball function

1. Program Description

In addition, the program simply realizes that after selecting a few bets through the user input machine, the two-color ball result is randomly selected, and the numbers in a group of results will not repeat, and the numbers are also marked with background colors, including blue balls and red balls.

2. Code implementation

import time
import random
r = []
b = []

num = int(input("机选几注:"))
for i in range(1, num+1):
    time.sleep(1)
    blue = [x for x in range (1,17)]
    red = [y for y in range (1,34)]
    a = random.choice(blue)
    b.append(a)
    for n in range(1, 7):
        d = random.randint(0, (len(red)-1))
        w = red.pop(d)
        r.append(w)
    print("\033[1;41m{:0>2d}\033[0m \033[1;41m{:0>2d}\033[0m \033[1;41m{:0>2d}\033[0m \033[1;41m{:0>2d}\033[0m \033[1;41m{:0>2d}\033[0m \033[1;41m{:0>2d}\033[0m | \033[1;44m{:0>2d}\033[0m\n".format(r[0], r[1], r[2], r[3], r[4], r[5], b[0]))
    del r[:]
    del b[:]

3. Running results

insert image description here

Guess you like

Origin blog.csdn.net/me_1984/article/details/106556191