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骰子猜大小游戏
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。