• Python_猜大小


     1 # 需要在python3上执行
     2 import random
     3 def game (capital = 1000):
     4     point1 = random.randrange(1,7)
     5     point2 = random.randrange(1,7)
     6     point3 = random.randrange(1,7)
     7     print("<<<<<<<<<< 游戏开始 >>>>>>>>>>")
     8     result = point3 + point2 + point1
     9     大 = range(11,19)
    10     小 = range(3,11)
    11     print("请选择大小,如果选择“大”请输入“大”,否则输入“小”")
    12     cai = input("大 or 小: ")
    13     if cai == '' or cai == '':
    14         print("您的本金有",capital)
    15         xiaZhu = input("您想下注多少钱?(请输入正整数,并且不能超过本金): ")
    16         if xiaZhu.isdigit():
    17             if abs(float(xiaZhu)) > capital:
    18                 print("***您下的注金不能高过您的本金,您的本金还有:",str(capital)+"元,请重新下注!
    ")
    19                 game(capital = capital)
    20             else:
    21                 print('<<<<<<<<< 买定离手,开始摇筛子了!!! >>>>>>>>>')
    22                 if cai == '':
    23                     if result in 大:
    24                         print("点数是"+ str([point3, point2, point1]),"You Win!")
    25                         capital = capital + abs(float(xiaZhu))
    26                         print('您赢得了'+ str(abs(float(xiaZhu)))+''+',您现在有'+ str(capital)+ '')
    27                     else:
    28                         print("摇得的点数是"+ str([point3, point2, point1]),"You Lose!")
    29                         capital = capital - abs(abs(float(xiaZhu)))
    30                         print('您输了' + str(xiaZhu) + '' + ',您现在有' + str(capital) + '')
    31                 else:
    32                     cai == ''
    33                     if result in 小:
    34                         print("点数是"+ str([point3, point2, point1]),"You Win")
    35                         capital = capital + abs(abs(float(xiaZhu)))
    36                         print('您赢得了' + str(abs(float(xiaZhu))) + '' + ',您现在有' + str(capital) + '')
    37                     else:
    38                         print("点数是"+ str([point3, point2, point1]),"You Lose!")
    39                         capital = capital - abs(float(xiaZhu))
    40                         print('您输了' + str(abs(float(xiaZhu))) + '' + ',您现在有' + str(capital) + '')
    41             if capital <=0:
    42                 print("*** 您的资金已经用光,GAME OVER!!! ***")
    43                 quit()
    44             else:
    45                 i = 1
    46                 while i > 0:
    47                     game(capital = capital)
    48         else:
    49             print("***下注资金只能是正整数,请您重新下注***
    ")
    50             game(capital = capital)
    51     else:
    52         print("***选择大小时仅允许输入 “大” 或 “小”,请重新下注!***
    ")
    53         game(capital = capital)
    54 game()
  • 相关阅读:
    (转)Delphi写COM+的心得体会
    delphi透明组件(控件)开发
    Delphi 常用组件常见属性说明
    DELPHI方面输入EDIT
    BYTE 转字符串
    椭圆按纽制作
    数据库实例学生名册管理系统(DAO的使用实验)
    数据库如何快速创建连接字符串
    数据库使用DataReader的简单实例(两种办法)
    数据库ADO.NET的结构
  • 原文地址:https://www.cnblogs.com/xuelei-0728/p/6230157.html
Copyright © 2020-2023  润新知