重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
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元起,快前往官网查看详情吧