Commit 4f610272 by BellCodeEditor

auto save

parent 25abb509
Showing with 49 additions and 1 deletions
逻辑运算符
and 和,与,且
or
not 非,不
条件判断
单分支:
if 今天上课:
好好听讲
双分支:(两种情况)
if 今天是周末:
休息
else: # 否则(今天不是周末)
上学
多分支:(两种以上情况)
if 今天是周一:
KFC
elif 今天是周二:
吃麦当劳
elif 今天是周三:
吃必胜客
... (周四)
... (周五)
... (周六)
else:(今天是周日)
吃华莱士
换行符:\n
\ No newline at end of file
player=input("请出拳:石头/剪刀/布")# 玩家出拳 import random # 导入随机数模块
player=input("请出拳:")
print("玩家出拳:"+player) print("玩家出拳:"+player)
list=["石头","剪刀","布"]
computer=random.choice(list) # 随机抽取(选取)
print("计算机出拳:"+computer) # QUAN
if player in list: # 判断玩家出拳是否为石头、剪刀或者布
if player==computer:
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