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实验脚本的更多相关文章

  1. Frenetic Python实验(三)

    实验5 repeater 这个实验在HelloSDNWorld里面做的实验是一样的.HelloSDNWorld 目的:模拟一个有多个端口的中继器. This application implement ...

  2. mininet实验 脚本实现控制交换机行为

    写在前面 本文参考 通过这个实验,我学习到了另一种下流表的方式. 下流表有两种方式(我目前了解): 通过controller下发. 通过OvS提供的API直接向OvS交换机下流表. 本实验脚本已经把相 ...

  3. 在.Net Framework中调用Python的脚本方法 (以VB和C#为例)

    某个项目中涉及到这样一个情景: VB/C#写的原始项目要调用Python的一些方法完成特殊的操作, 那么这就涉及到了,在.Net Framework中如何调用Python的脚本方法. 具体步骤流程如下 ...

  4. Python 通过脚本获取Android的apk的部分属性,再通过加密算法生成秘钥。

    Python 通过脚本获取Android的apk的部分属性,再通过加密算法生成秘钥. #!/usr/bin/env python # -*- coding: utf- -*- import os im ...

  5. Jenkins 为Jenkins添加Windows Slave远程执行python项目脚本

    为Jenkins添加Windows Slave远程执行python项目脚本   by:授客 QQ:1033553122 测试环境 JAVA JDK 1.7.0_13 (jdk-7u13-windows ...

  6. python 实验环境

    python 实验环境的搭建 刚开始在windows环境下尝试过komodo ,eclispse pydev,swing,spyder甚至limodou的编辑器,之后ipython,安装很多科学计算包 ...

  7. python爬虫脚本下载YouTube视频

    python爬虫脚本下载YouTube视频 爬虫 python YouTube视频 工作环境: python 2.7.13 pip lxml, 安装 pip install lxml,主要用xpath ...

  8. 使用 Python 编写脚本并发布

    使用 Python 编写脚本并发布 P1: 脚本 通常在 Linux 服务器上会遇到在命令行中输入命令的操作,而有些操作包含的命令数目较多或者其中的命令包含的参数较多,如果一个一个的敲命令的话就太麻烦 ...

  9. Appium环境的安装与配置,Python测试脚本测试

    Appium自动化测试系列1 - Appium环境的安装与配置 发表于4个月前(2015-01-27 14:34)   阅读(803) | 评论(0) 0人收藏此文章, 我要收藏 赞0 寻找 会’偷懒 ...

随机推荐

  1. 杂记(C语言中的不知怎么归类的细小点。)

    1.int a; printf("%d",2a); 从数学上讲,没有丝毫问题,但是在计算机上,就无法识别!        纠正:应写成2*a. 2.关于输出结果保留一位小数的:不应 ...

  2. 05-01 seaborn

    1.Seaborn 在上节中我们学习了matplotlib,这节课我们来看看另一个可视化的模块seaborn,它是基于matplotlib的更高级的开源库,主要用作于数据可视化,解决了matplotl ...

  3. R语言算法 ▪ 计算随意输入的两数之间的区域和

    sumfu<-function(a,b,n=){ if(a<b){ for(i in a:b){n=n+i} }else for(i in b:a){n=n+i} return <- ...

  4. [NewLife.XCode]分表分库(百亿级大数据存储)

    NewLife.XCode是一个有15年历史的开源数据中间件,支持netcore/net45/net40,由新生命团队(2002~2019)开发完成并维护至今,以下简称XCode. 整个系列教程会大量 ...

  5. Java Metrics工具介绍

    目录 简介 快速入门 Maven配置 MetricRegistry Gauge Meter Counter Histgram Timer Reporter 更多用法 参考资料 简介 Metric是一个 ...

  6. ubuntu16.04 下anaconda3安装教程

    贴一个成功的连接: https://blog.csdn.net/u012243626/article/details/82469174

  7. 你不得不知的Golang线程模型 [转载]

    原著:翟陆续(加多) 资深Java , 著Java并发编程之美 一.前言 本节我们来探讨Go的线程模型,首先我们先来回顾下常见的三种线程模型,然后在介绍Go中独特的线程模型. 二.三种线程模型 线程的 ...

  8. WPF 隐藏式控件

    没用Popup用的面板控件,全部代码使用xaml的触发器. 代码: <Grid> <DockPanel> <StackPanel Background=" Do ...

  9. DateTimeComparer

    public int Compare(string x,string y) { DateTime xDate = DateTime.ParseExact(x, "MMMM", ne ...

  10. python 处理中文遇到的编码问题总结 以及 字符str的编码如何判断

    如何处理中午编码的问题 Python的UnicodeDecodeError: 'utf8' codec can't decode byte 0xxx in position 这个错误是因为你代码中的某 ...