从品牌网站建设到网络营销策划,从策略到执行的一站式服务
1.两个变量—— 一个存放电脑产生的随机数,一个存放用户输入的数
成都创新互联公司专注于贵阳企业网站建设,响应式网站,成都做商城网站。贵阳网站建设公司,为贵阳等地区提供建站服务。全流程专业公司,专业设计,全程项目跟踪,成都创新互联公司专业和态度为您提供的服务2.判断输赢(0—石头,1—剪刀,2—布)
1.人赢(0—1,1—2,2—1)
2.平局
3.电脑赢
方法1:
import random
player = int(input("请出拳:0—石头,1—剪刀,2—布:")
computer = random.randint(0,2)
if (player == 0 and computer == 1) or (player == 1 and computer == 2) or (player == 2 and computer == 0):
print("恭喜获胜")
elif player == computer:
print("平局,再来一局")
else:
print("电脑赢")
方法2:
import random
computer = randon.randint(0,2)
player = int(input("请出拳:0—石头,1—剪刀,2—布:")
if (computer == 0 and player == 1) or (computer == 1 and player == 2) or (computer == 2 and player == 0):
print("电脑获胜")
elif player == computer:
print("平局,再来一局")
else:
print("恭喜获胜")
方法3:
import random
computer = randon.randint(0,2)
player = int(input("请出拳:0—石头,1—剪刀,2—布:")
if (player == 0 and computer == 1) or (player == 1 and computer == 2) or (player == 2 and computer == 0):
print("恭喜获胜")
elif (computer == 0 and player == 1) or (computer == 1 and player == 2) or (computer == 2 and player == 0):
print("电脑获胜")
else:
print("平局")
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧
成都网站建设公司地址:成都市青羊区太升南路288号锦天国际A座10层 建设咨询028-86922220
成都快上网科技有限公司-四川网站建设设计公司 | 蜀ICP备19037934号 Copyright 2020,ALL Rights Reserved cdkjz.cn | 成都网站建设 | © Copyright 2020版权所有.
专家团队为您提供成都网站建设,成都网站设计,成都品牌网站设计,成都营销型网站制作等服务,成都建网站就找快上网! | 成都网站建设哪家好? | 网站建设地图