摇骰子游戏升级

此次更改增加下注功能,启动资金1000元,每次赔率都是一倍,钱输光退出。

源码:

 #!/user/bin/env python
#-*-coding:utf-8 -*-
#Author: qinjiaxi
import random
#一次摇三个骰子并将结果存在列表中
def role_a_dice(number = 3, point = None ):
print('Let\'s play a game')
if point is None:
point = []
while number > 0:
point.append(random.randint(1, 6))
number -= 1
return point
#将结果转换成'大小'字符串
def dice_reslut(total):
isBig = 11 <= total <= 18
isSmall = 3 <= total <= 10
if isBig:
return "Big"
if isSmall:
return "Small"
def start_game(money = 1000):
while money > 0:
print("-----GAME START-----")
choices = ['Big', 'Small']
U_choices = input('pls enter your choice:')
if U_choices in choices:
money_choice = int(input('How much you wanna bet ? -'))
points = role_a_dice()#调用函数摇骰子得到三个骰子的结果
totals = sum(points)#三次结果相加得到最终点数
resluts = dice_reslut(totals)#调用函数得到将最终点数转换成字符串
if U_choices == resluts:
print('点数是:{}恭喜你猜对了'.format(points))
money += money_choice
print('you gain {}, you have:{} now'.format(money_choice,money))
else:
print('点数是:{}抱歉猜错了'.format(points))
money -= money_choice
print('you lost {}, you have:{} now'.format(money_choice, money))
else:
print('Invalid words.')
start_game()
else:
print('GAME OVER')
start_game()

三大运营商短信验证过滤

如果是三个运行商里的号码就发短信,号码不足11位提示

源码:

 !/user/bin/env python
#-*-coding:utf-8 -*-
#Author: qinjiaxi def verificate_number():
while True:
CN_mobile =[134,135,136,137,138,139,150,151,152,157,158,159,182,183,184,187,188,147,178,1705]
CN_union = [130,131,132,155,156,185,186,145,176,1709]
CN_telecom = [133,153,180,181,189,177,1700]
number = input('pls enter your number:')
first_three = int(number[0:3])
first_four = int(number[0:4])
if len(number) == 11:
if first_four in CN_mobile or first_three in CN_mobile:
print('operator is china mobile' )
print('we\'re sending verification code via text to your phone {}'.format(number))
break
elif first_four in CN_union or first_three in CN_union:
print('operator is china union')
print('we\'re sending verification code via text to your phone {}'.format(number))
break
elif first_four in CN_telecom or first_three in CN_telecom:
print('operator is china telecom')
print('we\'re sending verification code via text to your phone {}'.format(number))
break
else:
print('No such a operator')
else:
print('Invalid length, your number should be in 11 digits')
verificate_number()

最新文章

  1. Unity3D框架插件uFrame实践记录(二)
  2. 浅谈Excel开发:十一 针对64位Excel的插件的开发和部署
  3. Node 编程规范
  4. GRIDVIEW多行多列合并单元格(合并列)
  5. php用soap创建webservice
  6. php中intval()函数
  7. win7系统中任务计划程序的使用与查询
  8. jsp页面使用javascript添加页面元素示例代码
  9. codeforces C. Restore Graph
  10. RHEL7查看网卡配置命令ip addr show
  11. 使用Swing实现简易而不简单的文档编辑器
  12. Android实战简易教程-第九枪(BitmapFactory.Options对资源图片进行缩放)
  13. JMeter 插件 Json Path 解析HTTP响应JSON数据
  14. VBS 备份文件
  15. python 3.6.1 安装scrapy踩坑之旅
  16. 【Pthreads】Pipeline Model(Assembly Line)示例
  17. 目标检测技术演进:R-CNN、Fast R-CNN、Faster R-CNN
  18. 自然语言交流系统 phxnet团队 创新实训 个人博客 (十二)
  19. 99 Times--Kate Voegele
  20. JavaScript中的垃圾回收和内存泄漏

热门文章

  1. Django编写自定义manage.py 命令
  2. [Inno Setup] 开机自启动
  3. JavaScript正则表达式及jQuery回顾
  4. VMware虚拟机中centos6.5网络配置(桥接方式)与宿主机之间通信
  5. vim的四种工作模式(转载别人的)
  6. JS编程建议——11:慎重使用伪数组
  7. WordPress发布文章/页面时自动添加默认的自定义字段
  8. 51 NOD 1049 最大子段和 动态规划 模板 板子 DP
  9. 题解 bzoj 4398福慧双修(二进制分组)
  10. pyhton中绘制多个图像