python实现摇骰子猜大小函数升级没把加注及三大运行商短信验证过滤
摇骰子游戏升级
此次更改增加下注功能,启动资金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()
python实现摇骰子猜大小函数升级没把加注及三大运行商短信验证过滤的更多相关文章
- python实现简单投资复利函数以及实现摇骰子猜大小函数
复利函数: #!/user/bin/env python #-*-coding:utf-8 -*- #Author: qinjiaxi def invest(amount, rate, time): ...
- python 小游戏之摇骰子猜大小
最近学习Python的随机数,逻辑判断,循环的用法,就想找一些练习题,比如小游戏猜大小,程序思路如下: 开发环境:python2.7 , 附上源代码如下: 摇骰子的函数,这个函数其实并不需要传任何参数 ...
- python摇骰子猜大小的小游戏
#小游戏,摇筛子押大小的小游戏玩家初始有1000块钱,可以压大压小作为赌注 import random #定义摇筛子的函数: def roll_dice(number = 3,points = Non ...
- python基于LeanCloud的短信验证
python基于LeanCloud的短信验证 1. 获取LeanCloud的Id.Key 2. 安装Flask框架和Requests库 pip install flask pip install re ...
- 注册登录页面修订-Python使用redis-手机验证接口-发送短信验证
登录页面修订 views.Login.vue <template> <div class="login box"> <img src="@/ ...
- python数据挖掘第三篇-垃圾短信文本分类
数据挖掘第三篇-文本分类 文本分类总体上包括8个步骤.数据探索分析->数据抽取->文本预处理->分词->去除停用词->文本向量化表示->分类器->模型评估.重 ...
- [Python学习之路] 猜大小游戏
# coding =utf-8 import random def roll_dice(number=3, points=None): if points == None: points = [] w ...
- 用Python免费发短信,实现程序实时报警
进入正文 今天跟大家分享的主题是利用python库twilio来免费发送短信. 先放一张成品图: 代码放在了本文最后的地址中 正文 眼尖的小伙伴已经发现了上面的短信的前缀显示这个短信来自于一个叫Twi ...
- 使用 Python 发送短信?
上回食行生鲜签到,我们说到怎么把签到结果发出来,于是就找到了 Twilio. Twilio 是一个位于加利福尼亚的云通信(PaaS)公司,致力于为开发者提供通讯模块的 API.由于 Twilio 为试 ...
随机推荐
- Ubuntu中安装Hadoop
安装前 1,更新apt sudo apt-get update 会让你输入密码(自己登录Ubuntu的时候设置的),输入密码不会显示在终端面板上,确定自己敲对之后点回车就行. 2,安装SSH服务器 ...
- [Inno Setup] 执行程序,返回值不为0时提示用户
procedure LoadPerfCounter(); var Ret : Integer; begin if Exec(ExpandConstant('{sys}') + '\lodctr.exe ...
- MySQL系列(二)
查看\创建\使用\删除 数据库 用户管理及授权实战 局域网远程连接法 查看\创建\使用\删除\清空\修改 数据库表(是否可空,默认值,主键,自增,外键) 表内容的增删改查 where条件.通配符_%. ...
- 尤雨溪的vue怎么学,应该从vue-cli开始,为什么?
带手机验证码登陆, 带全套购物车系统 带数据库 前后端分离开发 带定位用户功能 数据库代码为本地制作好了 带支付宝支付系统 带django开发服务器接口教程 地址: https://www.dua ...
- bfs—Dungeon Master—poj2251
Dungeon Master Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 32228 Accepted: 12378 ...
- spark系列-4、spark序列化方案、GC对spark性能的影响
一.spark的序列化 1.1.官网解释 http://spark.apache.org/docs/2.1.1/tuning.html#data-serialization 序列化在任何分布式应用程序 ...
- 数学--数论--HDU 5019 revenge of GCD
Revenge of GCD Problem Description In mathematics, the greatest common divisor (gcd), also known as ...
- Jenkins 项目构建
一:新建项目 (1)点击新建,输入项目名称--构建一个自由风格的软件项目,点击ok (2)构建触发器-----设置每两分钟执行一次 其中有5个参数 (*****) 第一个是代表分钟 一小时内的分钟数 ...
- Effective C++学习记录
Effective C++算是看完了,但是并没有完全理解,也做不到记住所有,在此记录下55个条款及条款末的"请记住". 让自己习惯C++ 条款01:视C++为一个语言联邦 ① C ...
- 谷歌浏览器的F12用处及问题筛查笔记
在前端测试功能的时候,经常有些莫名其妙的错误,这个时候开发会说打开F12看一下吧,所以感觉这个开发者功能很有用,研究一下,做如下记录: Elements:左栏以DOM树形式查看网页源代码(HTML), ...