python 抽卡

模拟抽奖

import random
def main():
    print('weilcome to box game')
    print(' 1.once\n','2.sixty times\n','3.quit',end='')
    while True:
        c=input('\nplease choice: ')
        if int(c) == 1:
            once()
        elif int(c) == 2:
            sixty()
        elif int(c) == 3:
            print('Bye')
            break

def once():

    dict={'c':0,
          'r':0,
          'e':0,
          'l':0}
    print('\nSplit card package...')
    for i in range(0,5):
        n = random.randint(1,100)
        if n >= 1 and n <= 60:
            m='common'
            dict['c']=dict['c']+1
            print(m,end='   ')
        elif n >= 0 and n <= 85:
            m='rare'
            dict['r']=dict['r']+1
            print(m,end='   ')
        elif n >= 86 and n <= 97:
            m='epic!'
            dict['e'] = dict['e'] + 1
            print(m,end='   ')
        elif n >= 98 and n <= 100:
            m='legend!!'
            dict['l'] = dict['l'] + 1
            print(m,end='   ')
    return dict
def sixty():
    c1=0
    r1=0
    e1=0
    l1=0
    for i in range(0,60):
        c1=c1+once()['c']
        r1=r1+once()['r']
        e1=e1+once()['e']
        l1=l1+once()['l']
    dict2={
        'commom':c1,
        'rare':r1,
        'epic':e1,
        'legend':l1
    }
    print('\n','{} three is a legend!!!'.format(dict2['legend']))

main()
posted @ 2022-04-28 15:59  supermao12  阅读(266)  评论(0编辑  收藏  举报