zoukankan      html  css  js  c++  java
  • 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()
  • 相关阅读:
    UVALive 5066 Fire Drill --BFS+DP
    Codeforces 486E LIS of Sequence --树状数组求LIS
    Codeforces 460D Little Victor and Set --分类讨论+构造
    Codeforces Round #285 (Div.1 B & Div.2 D) Misha and Permutations Summation --二分+树状数组
    计算机组成原理知识总结
    HDU 5155 Harry And Magic Box --DP
    【Python数据分析】简单爬虫 爬取知乎神回复
    《查拉图斯特拉如是说》读书笔记
    POJ 3384 Feng Shui --直线切平面
    POJ 2540 Hotter Colder --半平面交
  • 原文地址:https://www.cnblogs.com/xuelei-0728/p/6230157.html
Copyright © 2011-2022 走看看