# 用python写玩家买筹码，下注，判断输赢的小游戏

1.第一次写

#第一次写
import random
isExit="n"
playerMoney = int(input("请输入您手里的筹码数量："))
while isExit=="n":

if 0<=playerMoney<50:
print("你筹码太少！很遗憾，只能退出")
isExit=="y"
break
elif playerMoney>=50:
xiaZhuMoney = int(input("至少要下注50，请下注："))

if (50<=xiaZhuMoney<=playerMoney):
lanziBigOrSmall=random.randint(1,6)
if (buyBigOrSmall == "大" and 4<=lanziBigOrSmall<=6):
print("你赢了，你选的大，骰子大小为%s"%lanziBigOrSmall)
playerMoney=playerMoney+xiaZhuMoney
print("你的当前筹码是%s"%playerMoney)
elif (buyBigOrSmall == "大" and 1<=lanziBigOrSmall<=3):
print("你输了，你选的大，骰子大小为%s"%lanziBigOrSmall)
playerMoney=playerMoney-xiaZhuMoney
print("你的当前筹码是%s"%playerMoney)

if 0<=playerMoney<50:
print("你筹码太少！很遗憾，只能退出")
isExit=="y"
break

elif (buyBigOrSmall == "小" and 4<=lanziBigOrSmall<=6):
print("你输了，你选的小，骰子大小为%s"%lanziBigOrSmall)
playerMoney=playerMoney-xiaZhuMoney
print("你的当前筹码是%s"%playerMoney)
if 0<=playerMoney<50:
print("你筹码太少！很遗憾，只能退出")
isExit=="y"
break
elif (buyBigOrSmall == "小" and 1<=lanziBigOrSmall<=3):
print("你赢了，你选的大，骰子大小为%s"%lanziBigOrSmall)
playerMoney=playerMoney+xiaZhuMoney
print("你的当前筹码是%s"%playerMoney)

else:
print("输入有误，请重新输入！")
isExit = input("是否要退出？y or n?")
if isExit=="y":
break
else:
print("您没有这么多筹码，请重新下注！")

else:
print("输入有误，请重新输入！")

#第一次写
import random
isExit="n"
playerMoney = int(input("请输入您手里的筹码数量："))
while isExit=="n":

if 0<=playerMoney<50:
print("你筹码太少！很遗憾，只能退出")
isExit=="y"
break
elif playerMoney>=50:
xiaZhuMoney = int(input("至少要下注50，请下注："))

if (50<=xiaZhuMoney<=playerMoney):
lanziBigOrSmall=random.randint(1,6)
if (buyBigOrSmall == "大" and 4<=lanziBigOrSmall<=6):
print("你赢了，你选的大，骰子大小为%s"%lanziBigOrSmall)
playerMoney=playerMoney+xiaZhuMoney
print("你的当前筹码是%s"%playerMoney)
elif (buyBigOrSmall == "大" and 1<=lanziBigOrSmall<=3):
print("你输了，你选的大，骰子大小为%s"%lanziBigOrSmall)
playerMoney=playerMoney-xiaZhuMoney
print("你的当前筹码是%s"%playerMoney)

if 0<=playerMoney<50:
print("你筹码太少！很遗憾，只能退出")
isExit=="y"
break

elif (buyBigOrSmall == "小" and 4<=lanziBigOrSmall<=6):
print("你输了，你选的小，骰子大小为%s"%lanziBigOrSmall)
playerMoney=playerMoney-xiaZhuMoney
print("你的当前筹码是%s"%playerMoney)
if 0<=playerMoney<50:
print("你筹码太少！很遗憾，只能退出")
isExit=="y"
break
elif (buyBigOrSmall == "小" and 1<=lanziBigOrSmall<=3):
print("你赢了，你选的大，骰子大小为%s"%lanziBigOrSmall)
playerMoney=playerMoney+xiaZhuMoney
print("你的当前筹码是%s"%playerMoney)

else:
print("输入有误，请重新输入！")
isExit = input("是否要退出？y or n?")
if isExit=="y":
break
else:
print("您没有这么多筹码，请重新下注！")

else:
print("输入有误，请重新输入！")

2.完善版

#完善版
import random
#买筹码
print("欢迎来到***豪华赌场！")
while True:
money = int(input("购买筹码不能小于50.请购买："))
if money<50:
print("筹码数量小于50，请重购买！")
else:
break
isGo = "y"
#下注
while True:
if money >= 50:
while True:
outmoney = int(input("请下注，至少50，您的下注金额是："))
money=money-outmoney
if 50 <= outmoney <= money+outmoney:
userbigorsmall = input("买大还是卖小？  我买：")
touzibigorsmall = random.randint(1,6)
if userbigorsmall == "小" and 1<=touzibigorsmall <= 3:
print("你赢了，你买的小,骰子点数是%s为小"%(touzibigorsmall))
money=money+outmoney*2
print("您的余额为：%s"%money)
elif userbigorsmall == "小" and 4<=touzibigorsmall <= 6:
print("你输了，你买的小,骰子点数是%s为大"%(touzibigorsmall))
print("您的余额为：%s"%money)
elif userbigorsmall == "大" and 4<=touzibigorsmall <= 6:
print("你赢了，你买的大,骰子点数是%s为大"%(touzibigorsmall))
money=money+outmoney*2
print("您的余额为：%s"%money)
else:
print("你输了，你买的大,骰子点数是%s为小"%(touzibigorsmall))
print("您的余额为：%s"%money)
isGo = input("是否继续你的梦想？y or n  你的选择是：")
if isGo == "n":
print("欢迎下次再来！")
#	sys.Exit()
SystemExit
else:
if money < 50:
print("余额不足，请充值")
break
elif outmoney < 50:
print("下注金额不能小于50，请重新下注！")
else:
print("下注金额超过您的余额，请重新下注！")
else:
break

#完善版
import random
#买筹码
print("欢迎来到***豪华赌场！")
while True:
money = int(input("购买筹码不能小于50.请购买："))
if money<50:
print("筹码数量小于50，请重购买！")
else:
break
isGo = "y"
#下注
while True:
if money >= 50:
while True:
outmoney = int(input("请下注，至少50，您的下注金额是："))
money=money-outmoney
if 50 <= outmoney <= money+outmoney:
userbigorsmall = input("买大还是卖小？  我买：")
touzibigorsmall = random.randint(1,6)
if userbigorsmall == "小" and 1<=touzibigorsmall <= 3:
print("你赢了，你买的小,骰子点数是%s为小"%(touzibigorsmall))
money=money+outmoney*2
print("您的余额为：%s"%money)
elif userbigorsmall == "小" and 4<=touzibigorsmall <= 6:
print("你输了，你买的小,骰子点数是%s为大"%(touzibigorsmall))
print("您的余额为：%s"%money)
elif userbigorsmall == "大" and 4<=touzibigorsmall <= 6:
print("你赢了，你买的大,骰子点数是%s为大"%(touzibigorsmall))
money=money+outmoney*2
print("您的余额为：%s"%money)
else:
print("你输了，你买的大,骰子点数是%s为小"%(touzibigorsmall))
print("您的余额为：%s"%money)
isGo = input("是否继续你的梦想？y or n  你的选择是：")
if isGo == "n":
print("欢迎下次再来！")
#    sys.Exit()
SystemExit
else:
if money < 50:
print("余额不足，请充值")
break
elif outmoney < 50:
print("下注金额不能小于50，请重新下注！")
else:
print("下注金额超过您的余额，请重新下注！")
else:
break