Python——机选大乐透

import random
import numpy as np


i=1
while i<=5:
    numbers_red=np.arange(1,36,1)
    numbers_blue=np.arange(1,13,1)
    computer_redballs,computer_blueballs = [],[]
    count_r = 1
    while count_r <= 5:
        index_r = random.randint(0, len(numbers_red)-1)
        number_r = numbers_red[index_r]
        computer_redballs.append(number_r)
        numbers_red=np.delete(numbers_red,index_r)
        count_r += 1
    count_b = 1    
    while count_b <= 2:
        index_b = random.randint(0, len(numbers_blue)-1)
        number_b = numbers_blue[index_b]
        computer_blueballs.append(number_b)
        numbers_blue=np.delete(numbers_blue,index_b)
        count_b += 1
    computer_redballs.sort()
    computer_blueballs.sort()
    print("第"+str(i)+"注""大乐透号码为:{}+".format(computer_redballs), end="")
    print("蓝色球号码为:{}".format(computer_blueballs))
    print("\n")
    i+=1

你可能感兴趣的:(Python,python,开发语言,前端)