import random
def roll(numbers = 3,points = None):
print("开始游戏")
if points is None :
points = []
while numbers > 0 :
point =random.randrange(1,7)
points.append(point)
numbers = numbers-1
return points
def roll_set(total):
isBig = 11 <= total <=18
isSmall = 3 <= total <= 10
if isBig:
return 'Big'
elif isSmall:
return 'Small'
def startgame():
Havemoney = 1000
while Havemoney > 0 :
print('<<<<<<Game Starts !!!>>>>>>')
choice = ['Big','Small']
yourchoice = input('Big or Small :')
if yourchoice in choice :
yourbet = int(input(' 你打算玩几块钱的? :'))
points = roll()
total = sum(points)
youwin = yourchoice == roll_set(total)
if Havemoney- yourbet < 0 :
print('你没有那么多钱,请重新输入')
startgame()
else :
pass
if youwin :
print('骰子为',points,'好吧你赢了')
Havemoney = Havemoney+yourbet
print('你还有%d元!'%Havemoney)
else :
print('骰子为',points,'你输了,继续努力!')
Havemoney = Havemoney - yourbet
print('你还剩%d元,下把搏一搏,单车变摩托'%Havemoney)
else:
print('输入的指令有错,请重新输入')
else :
print('游戏结束!!!')
startgame()
Python骰子猜大小游戏
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...