°

python3开发剪刀石头布小游戏

2019年课程规划及价格说明


PHP实战视频教程大全
import random
player = int(input("开始-石头(1)-剪刀(2)-布(3):"))
computer = random.randint(1, 3)

if player == 1:
    player_option = "石头"
elif player == 2:
    player_option = "剪刀"
elif player == 3:
    player_option = "布"
else:
    print("请输入有效值")

if computer == 1:
    computer_option = "石头"
elif computer == 2:
    computer_option = "剪刀"
elif computer == 3:
    computer_option = "布"
else:
    print("请输入有效值")

if (player==1 and computer==2) or (player==2 and computer==3) or (player==3 and computer==1):
    print("你出的是%s,我出的是%s,恭喜你赢了!"%(player_option, computer_option))
elif player == computer:
    print("你出的是%s,我出的也是%s,平局,再来!"%(player_option, computer_option))
else:
    print("你出的是%s,我出的是%s,哈哈我赢了!"%(player_option, computer_option))
打赏
  喜欢