1. 程式人生 > >python小遊戲,石頭/剪子/布

python小遊戲,石頭/剪子/布

#從控制檯輸入石頭(1)/剪子(2)/布(3)

player=int(input("玩家出拳 石頭(1)/剪子(2)/布(3)"))

#電腦隨機出拳 computer

computer == 1

print("玩家出的拳是%d - 電腦出的拳是%d" %(player , computer))

#玩家選擇出拳%d player 

if (player == 1 and computer == 2)or(player == 2 and computer == 3)or( player == 3 and computer == 1):

  print("電腦弱爆了")

 

#比較勝負

elif player =computer:

  print("心有靈犀,再來一局")

#平局

#電腦勝出

else:

print("電腦勝出")