猜大小 小游戏: import random print('《——————————————欢迎来到老****游戏厅——————————————》') print('~~~~~游戏规则介绍:~~~~~\n1:每局消耗5枚金币。\n2:金币兑换比例1元=10金币。') conins = 0 # 金币数量; sumMoney = 0 # 账户余额; monry_count = 0 # 充值次数 Cumulative_money = 0 # 合计充值金额 money = 0 # 充值金额 choice = 0 # 选择条件 0选择项目1充值2兑换3游戏开始4结束 gems_conins = 0 # 游戏次数 win_gems = 0 defeat_gems = 0 win_money = 0 # 赢了多少金币 defeat_conins = 0 # 输了多少金币 print('账户余额:%d元 ,账户金币余额:%d个' % (sumMoney, conins)) choice = int(input('1:继续充值。\n2:兑换金币。\n3:开始游戏。\n4:按任意退出。\n')) while choice == 0 or choice == 1 or choice == 2 or choice == 3 or choice == 4: while choice == 0: choice = int(input('1:继续充值。\n2:兑换金币。\n3:开始游戏。\n4:按任意退出。\n')) while choice == 1: money = int(input('请输入充值金额(整数金额):\n')) Cumulative_money += money print('恭喜您获得本次福利,赠送10%金额:') sumMoney += money * 1.1 # 赠送10%金额 monry_count += 1 # 计数充值次数 print('账户金币余额:%d元 账户金币余额:%d个' % (sumMoney, conins)) print('账户充值次数:%d/次 累计充值金额:%d元 赠送金额:%d元' % (monry_count, Cumulative_money, (Cumulative_money * 0.1))) print('请选择游戏项目:') choice = int(input('1:继续充值。\n2:兑换金币。\n3:开始游戏。\n4:按任意退出。\n')) while choice == 2: # 兑换金额 if sumMoney != 0: print('是否将账户余额:%d元。全部兑换,可兑换金币数量:%d个。' % (sumMoney, sumMoney * 10)) yes_1 = int(input('是否全部兑换(1继续。0:退出))')) else: print('是否将账户余额:%d元。全部兑换,可兑换金币数量:%d个。' % (sumMoney, sumMoney * 10)) print('账户余额不足,自动退出兑换功能:') yes_1 = 0 if yes_1 == 1: conins += int(sumMoney) * 10 # 兑换金币: sumMoney = 0 print('恭喜您成功兑换金币数量:%d个。' % conins) print('账户余额:%d' % sumMoney) choice = int(input('请选择游戏项目:\n1:继续充值。\n2:兑换金币。\n3:开始游戏。\n4:按任意退出。\n')) elif yes_1 == 0: choice = int(input('1:继续充值。\n2:兑换金币。\n3:开始游戏。\n4:按任意退出。\n')) while choice == 4: # 退出游戏 print('退出游戏:\n账户余额:%d元\n金币余额:%d\n ' % (sumMoney, conins)) print('共计玩了:%d次' % gems_conins) print('恭喜您一共赢了:%d元' % win_money) print('一共赢了:%d次' % win_gems) print('人品不行您输了:%d元' % defeat_conins) print('一共输了:%d次' % defeat_gems) print('账户余额:%d' % sumMoney) print('账户金币余额:%d' % conins) print('~~~~~~~~~~~~欢迎下次光临~~~~~~~~~~~~') print('《——————————————欢迎来到老****游戏厅——————————————》') choice = 5 break while choice == 3: # 游戏开始 if conins >= 5: conins = conins - 5 gems_conins += 1 ran_1 = random.randint(1, 6) ran_2 = random.randint(1, 6) sum_1 = ran_2 + ran_1 # gems_conins += 1 print(sum_1) geams = input('(提示:两枚骰子之和大于6结果为大.两枚骰子之和小于6结果为小 )\n请输入您猜的大或小:') if (sum_1 > 6 and geams == '大') or (sum_1 <= 6 and geams == '小'): # 猜对了 win_money += 15 conins += 15 print('恭喜您猜对了') print('金币余额:%d个' % conins) win_gems += 1 yes_2 = int(input('是否继续:1:继续 或0:返回')) if yes_2 == 1: choice = 3 else: choice = 3 print('请重新选择游戏项目:') choice = int(input('请选择游戏项目:\n1:继续充值。\n2:兑换金币。\n3:开始游戏。\n4:按任意退出。\n')) else: # 猜错了 print('您猜错了:1继续,:0:返回') print('金币余额:%d' % conins) defeat_conins += 15 defeat_gems += 1 yes_3 = int(input('是否继续1或0')) if yes_3 == 1: choice = 3 elif yes_3 == 0: choice = 3 choice = int(input('请选择游戏项目:\n1:继续充值。\n2:兑换金币。\n3:开始游戏。\n4:按任意退出。\n')) else: print('金币数量不足不能继续游戏<_>') print('账户余额:%d元' % sumMoney) yes_4 = int(input('是否兑换金币:1:充值。0退出游戏')) if yes_4 == 1: choice = 1 else: choice = 4
Python入门小游戏,猜大小:
最新推荐文章于 2024-02-26 12:18:03 发布