python—模拟生成双色球号和大乐透号


下边这个脚本,比较适合初级学习基本python语法用。但是,不精炼建议可参考https://www.cnblogs.com/Formulate0303/p/14031748.html的写法。

大乐透玩法:超级大乐透基本投注是指从前区号码中任选5个号码,并从后区号码中任选2个号码的组合进行投注。其中,前区号码由01—35共35个号码组成,后区号码由01—12共12个号码组成。(不放回抽取)

 

 

# -*- coding: UTF-8 -*-<br># 68喜科技

from  random  import  choice
# 随机生成一张双色球彩票
def  getAcaipiao():
     redball  =  [ "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" "14" "15" "16" "17" ,
                "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" ]
     blueball  =  [ "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" "14" "15" "16" ]
 
     count  =  0
     bcount  =  0
     redno  =  []
     blueno  =  []
     # 33选5
     while  count <  6 :
         temp  =  choice(redball)
         if  temp  in  redno:
             continue
         else :
             redno.append(temp)
             count  =  count  +  1
 
     blueno.append(choice(blueball))
 
     # 对红球数组进行升序排列
 
     redno.sort()
     return  redno  +  blueno
 
 
# 随机生成一张大乐透彩票
def  getBcaipiao():
     redball  =  [ "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" "14" "15" "16" "17" ,
                "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" ,
                "35" ]
     blueball  =  [ "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" ]
 
     count  =  0
     bcount  =  0
     redno  =  []
     blueno  =  []
     # 33选5
     while  count <  5 :
         temp  =  choice(redball)
         if  temp  in  redno:
             continue
         else :
             redno.append(temp)
             count  =  count  +  1
 
     while  bcount <  2 :
         temp  =  choice(blueball)
         if  temp  in  blueno:
             continue
         else :
             blueno.append(temp)
             bcount  =  bcount  +  1
 
     # 对红球数组进行升序排列
 
     redno.sort()
     blueno.sort()
     return  redno  +  blueno
 
 
print  u "双色球号码:"
print  getAcaipiao()
print  u "大乐透号码:"
print  getBcaipiao()
 
input  =  raw_input ("")
print  input
 
 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM