Commit f4ff57ee by BellCodeEditor

auto save

parent 32582699
Showing with 19 additions and 3 deletions
import random # 导入random模块
# 玩家出拳 # 玩家出拳
a=input("请出拳(石头/剪刀/布):") player = input("玩家出拳(石头/剪刀/布):") # 输入的内容
print("玩家出:"+a) print("玩家出:" + player) # 打印出:玩家出:+输入的内容
\ No newline at end of file # 计算机随机出拳
list = ["石头","剪刀","布"] # 建立列表
computer=random.choice(list) # 在列表中随机抽取一个元素
pint("计算机出拳:" + computer)
# 显示结果
# 完善输入错误时的情况
if play in list:
if player == computer: # if条件判断,如果玩家出=计算机出拳
print("平局") # 打印出,平局
elif (player=="石头" and computer=="剪刀")or(player=="剪刀" and computer=="布")or(player=="布" and computer=="石头"):
print("恭喜,你赢了") # 打印出,你赢了 ^如果不平局,将继续判断以上内容
else: # 否则
print("很遗憾,你输了") # 打印出,你输了
else: # 否则
print("输入错误") # 打印出,输入错误
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment