From a1485485d5a9b6b3c13c151de3ca496c9693bad5 Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Thu, 1 Dec 2022 20:54:57 +0800 Subject: [PATCH] save project --- diy1.py | 37 ++++++++++++++++++++----------------- 猜拳.py | 23 +++++++++++++++++++++++ 2 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 猜拳.py diff --git a/diy1.py b/diy1.py index b40b107..4ef3094 100644 --- a/diy1.py +++ b/diy1.py @@ -1,21 +1,24 @@ import random list=["石头","剪刀","布"] -player=input("请出拳:石头/剪刀/布 ")# 玩家出拳 -if player in list: - print("玩家出拳:"+player) - a=random.choice(list) - print("计算机出拳:"+a) - if player==a: - print("平局") - elif player=="石头" and a=="剪刀": - print("玩家赢") - elif player =="剪刀" and a=="布": - print("玩家赢") - elif player =="布" and a=="石头": - print ("玩家赢") +while True: + player=input("请出拳:石头/剪刀/布 ")# 玩家出拳 + if player=='1': + break + if player in list: + print("玩家出拳:"+player) + a=random.choice(list) + print("计算机出拳:"+a) + if player==a: + print("平局") + elif player=="石头" and a=="剪刀": + print("玩家赢") + elif player =="剪刀" and a=="布": + print("玩家赢") + elif player =="布" and a=="石头": + print ("玩家赢") + else: + print("玩家输") else: - print("玩家输") -else: - print("输入错误") - + print("输入错误") +print("游戏结束") diff --git "a/\347\214\234\346\213\263.py" "b/\347\214\234\346\213\263.py" new file mode 100644 index 0000000..e2728d0 --- /dev/null +++ "b/\347\214\234\346\213\263.py" @@ -0,0 +1,23 @@ +import random +list=["石头","剪刀","布"] +while True: + player=input("请出拳:石头/剪刀/布 ")# 玩家出拳 + if player=='1': + break + if player in list: + print("玩家出拳:"+player) + a=random.choice(list) + print("计算机出拳:"+a) + if player==a: + print("平局") + elif player=="石头" and a=="剪刀": + print("玩家赢") + elif player =="剪刀" and a=="布": + print("玩家赢") + elif player =="布" and a=="石头": + print ("玩家赢") + else: + print("玩家输") + else: + print("输入错误") +print("游戏结束") -- libgit2 0.25.0