码迷,mamicode.com
首页 > 其他好文 > 详细

生成5+2, 6+1的随机数

时间:2020-06-22 13:24:29      阅读:60      评论:0      收藏:0      [点我收藏+]

标签:print   sort   app   add   python   组合   numbers   def   TBase   

import random

def getBaseBigHapppyNumbers():
    frontNumbers = set();
    backNumbers = set();

    while(len(frontNumbers)<5):
        cur = random.randint(1, 35)
        frontNumbers.add(cur)
    while(len(backNumbers)<2):
        cur = random.randint(1, 12)
        backNumbers.add(cur)
    sorted(frontNumbers)
    sorted(backNumbers)
    print("随机的组合为:")
    print(frontNumbers)
    print(backNumbers)

def getDoubleColorBall():
    frontNumbers = set();
    backNumbers = set();

    while(len(frontNumbers)<6):
        cur = random.randint(1, 33)
        frontNumbers.add(cur)
    while(len(backNumbers)<1):
        cur = random.randint(1, 16)
        backNumbers.add(cur)
    sorted(frontNumbers)
    sorted(backNumbers)
    print("随机的组合为:")
    print(frontNumbers)
    print(backNumbers)

if __name__ == ‘__main__‘:
    getBaseBigHapppyNumbers()
    getDoubleColorBall()

  

生成5+2, 6+1的随机数

标签:print   sort   app   add   python   组合   numbers   def   TBase   

原文地址:https://www.cnblogs.com/yspworld/p/13175956.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!