Commit 32ba46f4 by BellCodeEditor

auto save

parent 91ed362a
Showing with 6 additions and 5 deletions
# 玩家出拳
player = input("请出拳(石头/剪刀/布): ") # 输入的内容
print("玩家出: "+player) # 打印出:玩家出:+输入的内容
player = input("请出拳(石头/剪刀/布) ") # 输入的内容
print("玩家出拳:" + player) # 打印出:玩家出:+输入的内容
# 计算机出拳
import random # 导入random模块
list=["石头","剪刀","布"] # 建立列表
computer = random.choice(list) # 在列表中抽取随机元素
pint("计算机出拳:"+computer)
print("计算机出拳:" + computer)
# 显示结果
if player == computer # if条件判断,如果玩家出=计算机出
if player == computer: # if条件判断,如果玩家出=计算机出
print("平局") # 打印出,平局
elif(player=="石头"and computer=="剪刀")or(player=="剪刀"and computer=="布")or(player=="石头"and computer=="布"): # 如果不平局,继续判断这段条件
elif (player=="石头" and computer=="剪刀")or(player=="剪刀" and computer=="布")or(player=="石头" and computer=="布"): # 如果不平局,继续判断这段条件
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