Commit 3ebe659b by BellCodeEditor

auto save

parent c45bc747
Showing with 6 additions and 11 deletions
...@@ -2,13 +2,8 @@ ...@@ -2,13 +2,8 @@
player=input("玩家请出拳:") player=input("玩家请出拳:")
print("玩家出拳是:"+player) print("玩家出拳是:"+player)
# 电脑出拳 # 电脑出拳
import random # 导入random模块 # 导入random模块
list=["剪刀","石头","布"]# 创建list列表,储存 剪刀,石头,布 # 创建list列表,储存 剪刀,石头,布
computer = random.choice(list)# 设置电脑出拳 使用computer变量 和 random.choice()方法 # 设置电脑出拳 使用computer变量 和 random.choice()方法
print("电脑出拳是:"+computer) # 输出"电脑出拳是:" # 输出"电脑出拳是:"
if player==computer: # 判断出拳结果,用if~elif~else
print("平局") \ No newline at end of file
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