'需求分析
参与游戏的角色1,玩家
手动出拳2.电脑
随机出拳(1固定出拳)
判断输赢1.玩家获胜2.平局3.电脑获胜'''
play =int(input('请出拳吧:0--石头,1--剪刀,2--布'))
computer =1
if ((play==0)and(computer ==1))or ((play==2)and(computer ==0))or ((play==1)and(computer ==2)):
print("赢了")
elif (play==computer):
print('平局,重新来')
else:
print('输了')
-------------------------------------------------------
a ='石头'
b ='剪刀'
c ='布'
guess =str(input('请输入你要出的手势'))
if guess == a:
print(f'对方出的是{b},你赢了')
elif guess == b:
print(f'对方出的是{b},平局!')
elif guess == c:
print(f'对方出的是{b},你输了')
网友评论