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 为试 ...
随机推荐
- ES[7.6.x]学习笔记(三)新建索引
与ES的交互方式 与es的交互方式采用http的请求方式,请求的格式如下: curl -X<VERB> '<PROTOCOL>://<HOST>:<PORT& ...
- 实体识别中,或序列标注任务中的维特比Viterbi解码
看懂这个算法,首先要了解序列标注任务 QQ522414928 可以在线交流 大体做一个解释,首先需要4个矩阵,当然这些矩阵是取完np.log后的结果, 分别是:初始strat→第一个字符状态的 ...
- ASP.NET Core Razor Pages 初探
最近新建 Asp.net Core MVC 项目的时候不小心选错了个模板,发现了一种新的项目模板.它使用cshtml视图模板,但是没有Controller文件夹.后来才发现这是ASP.NET Core ...
- BUAA_OO 第一单元总结
1.简单多项式求导 第一次作业的难点,我认为是对输入的预处理,尤其是正则表达式的使用.这次作业的思路是:首先将表达式进行预处理,(由于题目中要求不会有空格产生的WF,所以可以放心大胆的消除空格). 消 ...
- 今天,VS Code 五岁了。
时光飞逝,岁月如梭.今天,VS Code 迎来了 5 岁的生日. 回想起 VS Code 发布的那一天,仿佛还在昨天. 回顾 VS Code 这五年的发展,总是能给我们开发者带了无限的惊喜. 2015 ...
- Prometheus+Grafana 监控 Docker
cAdvisor (Container Advisor) :用于收集正在运行的容器资源使用和性能信息. https://github.com/google/cadvisor Prometheus(普罗 ...
- Java的循环语句
一.while 循环 while(循环条件){ 循环操作语句 } * 循环3要素: 变量的初值.变量的判断.变量的更新 * 缺少循环变量的更新,循环将一直进行下去 public class Whlie ...
- js数组排序和打乱
js数组根据不同的业务需求,会要求数组有序或者无序,记录一下流传较广,通用性较强的排序和乱序方法. 数组排序: arr.sort(function(a,b){//从小到大 return a-b;[re ...
- vlookup匹配不出,明明文本内容是一样的,求解答。
看起来很简单,肉眼看都知道就是匹配他,但是就是匹配不出.用trim去掉了空格,用分列去掉空格.tab这些看不见的.也改了单元格是数字型,而且粘贴是用数值型粘贴,全都匹配不出用if函数验证两个匹配对象是 ...
- 图论--差分约束--HDU\HDOJ 4109 Instrction Arrangement
Problem Description Ali has taken the Computer Organization and Architecture course this term. He le ...