python实验脚本
day1
1. 任性猜数字
需求 : 猜数字, 猜3次。如果对了 就直接退出。 如果3次都错了 ,就询问 要不要继续。
实现点: 使用 whie 循环。 count 进行计数。如果count >=3(猜错3次了) 就询问(交互式,输入N/n 退出)要不要继续, 如果继续,count归0 。重新开始。
# Author ricky age_of_name = 56 count = 0
while count < 3 :
age= int(input("age:"))
if age_of_name == age:
print ("you got it.")
break
elif age_of_name > age:
print ("think bigger.")
else:
print ("think smaller.")
count = count + 1
if count == 3:
flag_guess = input ("do you want continue. N/n(exit)/default(continue)")
if flag_guess != ("N") and flag_guess != ("n") :
count = 0
day 2
购物车脚本
# Author ricky products_list=[
("mac","10000"),
("book","60"),
("bick","800"),
("coffee","30"),
("T_shirt","100")
] shopping_list=[] while True:
salary = input("Please input your salary:")
if salary.isdigit():
salary = int(salary)
while True:
for index,item in enumerate(products_list):
print ( index, item )
user_choise = input("input your choise:")
if user_choise.isdigit():
user_choise = int(user_choise)
if user_choise >= 0 and user_choise < len(products_list):
p_item = products_list[user_choise]
p_money = int(p_item[1])
if salary >= p_money:
shopping_list.append( p_item )
salary = salary - p_money
print ("You have bought \033[31;1m%s\033[0m,and you current balance is \033[32;1m%s\033[0m" %(shopping_list,salary))
else:
print( "You do not have enough money, You current balance is \033[31,1m%s\033.[0m" %salary )
else:
print ("Invaild input")
elif user_choise == ("q"):
print ("--------------- shopping_list---------------")
print (shopping_list,"Your current balance is \033[31;1m%s\033[0m" %salary )
exit()
else:
print (" Input serise number")
else:
print ("Please input num")
day2 三级菜单
# Author ricky
data = {
"猫腻": {
"间客":{
"male":"徐乐",
"female": "张小萌"
},
"择天记":{
"male":"长生" ,
"famale":"有容"
},
"庆余年": {
"male":"范暹" ,
"famale":"千落"
}
},
"唐三":{
"狂神":"",
"善良的死神":"",
"斗罗大陆" : ""
},
"烟雨江南": {
"亵渎":"",
"罪恶之城":"",
"小二":""
}
}
exit_flag = True
while exit_flag:
for i in data:
print (i)
print ( "you can inpint place " , "b is return"," q is exit" )
choise1 = input ("Please choise:" )
if choise1 in data:
while exit_flag:
for i2 in data[choise1]:
print ("\t",i2)
print("you can inpint place ", "b is return", " q is exit")
choise2 = input("Please choise:")
if choise2 in data[choise1]:
while exit_flag :
print (data[choise1][choise2])
print ("the last level,while reture B: reture Q:exit")
choise3 = input ("Please choise:")
if choise3 == "b":
break
elif choise3 =="q":
exit_flag = False
elif choise2 == ("q"):
exit_flag = False
elif choise2 == ("b"):
break
elif choise1 == ("q") :
exit_flag = False
python实验脚本的更多相关文章
- Frenetic Python实验(三)
实验5 repeater 这个实验在HelloSDNWorld里面做的实验是一样的.HelloSDNWorld 目的:模拟一个有多个端口的中继器. This application implement ...
- mininet实验 脚本实现控制交换机行为
写在前面 本文参考 通过这个实验,我学习到了另一种下流表的方式. 下流表有两种方式(我目前了解): 通过controller下发. 通过OvS提供的API直接向OvS交换机下流表. 本实验脚本已经把相 ...
- 在.Net Framework中调用Python的脚本方法 (以VB和C#为例)
某个项目中涉及到这样一个情景: VB/C#写的原始项目要调用Python的一些方法完成特殊的操作, 那么这就涉及到了,在.Net Framework中如何调用Python的脚本方法. 具体步骤流程如下 ...
- Python 通过脚本获取Android的apk的部分属性,再通过加密算法生成秘钥。
Python 通过脚本获取Android的apk的部分属性,再通过加密算法生成秘钥. #!/usr/bin/env python # -*- coding: utf- -*- import os im ...
- Jenkins 为Jenkins添加Windows Slave远程执行python项目脚本
为Jenkins添加Windows Slave远程执行python项目脚本 by:授客 QQ:1033553122 测试环境 JAVA JDK 1.7.0_13 (jdk-7u13-windows ...
- python 实验环境
python 实验环境的搭建 刚开始在windows环境下尝试过komodo ,eclispse pydev,swing,spyder甚至limodou的编辑器,之后ipython,安装很多科学计算包 ...
- python爬虫脚本下载YouTube视频
python爬虫脚本下载YouTube视频 爬虫 python YouTube视频 工作环境: python 2.7.13 pip lxml, 安装 pip install lxml,主要用xpath ...
- 使用 Python 编写脚本并发布
使用 Python 编写脚本并发布 P1: 脚本 通常在 Linux 服务器上会遇到在命令行中输入命令的操作,而有些操作包含的命令数目较多或者其中的命令包含的参数较多,如果一个一个的敲命令的话就太麻烦 ...
- Appium环境的安装与配置,Python测试脚本测试
Appium自动化测试系列1 - Appium环境的安装与配置 发表于4个月前(2015-01-27 14:34) 阅读(803) | 评论(0) 0人收藏此文章, 我要收藏 赞0 寻找 会’偷懒 ...
随机推荐
- 【[POI2012]TOU-Tour de Byteotia】
[[POI2012]TOU-Tour de Byteotia] 洛谷P3535 https://www.luogu.org/problemnew/show/P3535 JDOJ 2193旅游景点(同类 ...
- gitbook 入门教程之解决windows热加载失败问题
破镜如何贴花黄 gitbook 在 Windows 系统无法热加载,总是报错! gitbook 是一款文档编写利器,可以方便地 markdown 输出成美观优雅的 html ,gitbook serv ...
- 学习:反调试之IsDebuggerPresent
前言:一个反调试IsDebuggerPresent的CreackMe IsDebuggerPresent函数的了解: IsDebuggerPresent 作用 确定调用进程是否由用户模式的调试器调试. ...
- NOIP模拟赛1(one)
题目描述 Description 很久以前,有一个序列,序列里填了一些非负整数. \(zzq\) 每次可以选择序列的一个前缀,把这个前缀里的数都-1,如果这个前缀 中有 0 操作就无法进行. \(zz ...
- jQuery与IE兼容性问题处理
jQuery虽然是兼容所有主流的浏览器,但实际应用中也会存在很多兼容性的问题.使用IE11+jquery-3.2.1.min.js遇到的问题如: 对象不支持indexOf 在低版本中,1.8写法如下: ...
- 数据分析常用的Excel函数
Excel是我们工作中经常使用的一种工具,对于数据分析来说,这也是处理数据最基础的工具. 本文对数据分析需要用到的函数做了分类,并且有详细的例子说明,文章已做了书签处理,点击可跳转至相应位置. 函数分 ...
- angular修改端口号port
报错:Port 4200 is already in use. Use '--port' to specify a different port. 因为4200端口已被使用,请使用“--port”修改 ...
- ELK 框架整体流程编写 以及logstash脚本编写
Elasticsearch Elasticsearch 是一个实时的分布式搜索和分析引擎,它可以用于全文搜索,结构化搜索以及分析.它是一个建立在全文搜索引擎 Apache Lucene 基础上的搜索引 ...
- ‘Maximum call stack size exceeded’错误的解决方法
今天打开vue项目,页面空白报了一个错误,错误如下: “Maximum call stack size exceeded” 错误的字面意思是:超出最大调用堆栈大小. 然后就是各种百度,找错误原因.百度 ...
- MySQL for OPS 02:SQL 基础
写在前面的话 上一节主要谈谈 MySQL 是怎么安装的以及最简单的初始化我们应该做哪些配置.其中也用到了一些简单的用户操作 SQL,所以这一节主要学习常用的 SQL 使用. SQL 介绍 在了解 SQ ...