Python:利用条件判断语句简单编写猜拳游戏

import random

player = int(input('请输入0(石头),1(剪刀),2(布):'))
computer = random.randint(0,2)

if (player == 0 and computer == 1) or (player == 1 and computer == 2) or (player == 2 and computer == 0):
    print('电脑出的是',computer,'你出的是',player,'你赢了')
elif (player == computer):
    print('电脑出的是',computer,'你出的是',player,'平手')
else:
    print('电脑出的是',computer,'你出的是',player,'你输了')

你可能感兴趣的:(python)