LMS知識社群歷程檔案Login
Position: 吳驊軒 > GBook > 考試py
import random
dic={1:'棒',2:'老虎',3:'雞',4:'蟲'}
dic1={-1:'輸',0:'平手',1:'贏'}
while(1):
    x=random.randint(1,4)
    a=int(input('1:棒,2:老虎,3:雞,4:蟲'))
    print('隨機數:',x)
    print('你出',dic[a],'電腦出',dic[x])
    if(x-a==3):
        print(dic1[-1])
    elif(x-a==-3):
        print(dic1[1])
    elif(x-a not in dic1 ):
        print(dic1[0])
    else:
        print(dic1[x-a])    
    z=input('if you want to play again input (y):')
    if(z!='y'):
        break       
Reply