随机码的生成,python 2.7/eclipse 3.7+PyDev 2.4.0

import random
print 'Red balls and blue ball are created program!'
a = raw_input('Do you want to create numbers?(Y/N)')
list1 = ['y','Y',]
list2 = ['n','N',]
if a in list2:
    print 'Quit program,please rerun!'
else:
    if a in list1:
        redList = set()
        bullList = set()
        while len(redList)<7:
            redList.add(random.randint(1,34))
        while len(bullList)<1:
            bullList.add(random.randint(1,17))
        print 'Red balls are:',list(redList),'Blue ball is:',list(bullList)
    else:
        print 'Only input y or n'

 

你可能感兴趣的:(python,Random)