python系统学习日记 L22~L24 练习
L22~L23:无
L24:
书中代码:
print "Let's practice everything."
print 'You\'d need to know \'bout escapes with \\ that do \n newlines and \t tabs.'poem = """
\tThe lovely world
with logic so firmly planted
cannot discern \n the needs of love
nor comprehend passion from intuition
and requires an explanation
\n\t\twhere there is none.
"""print "--------------"
print poem
print "--------------"five = 10 - 2 + 3 - 6
print "This should be five: %s" % fivedef secret_formula(started):jelly_beans = started * 500jars = jelly_beans / 1000crates = jars / 100return jelly_beans, jars, cratesstart_point = 10000
beans, jars, crates = secret_formula(start_point)print "With a starting point of: %d" % start_point
print "We'd have %d beans, %d jars, and %d crates." % (beans, jars, crates)start_point = start_point / 10print "We can also do that this way:"
print "We'd have %d beans, %d jars, and %d crates." % secret_formula(start_point)
代码修改为:
print("Let's practice everything.")
print('You\'d need to know \'bout escapes whit \\ that do \n new lines and \t tabs.')poem = """
\tThe lovely world
with logic so firmly planted
cannot discern \n the needs of love
nor comprehend passion from intuition
and requires an explanation
\n\t\twhere there is none.
"""print("----------")
print(poem)
print("----------")five = 10 - 2 + 3 - 6
print("This should be five: %s" % five)def secret_formula(started):jelly_beans = started * 500jars = jelly_beans / 1000crates = jars / 100return jelly_beans, jars, cratesstart_point = 10000
beans, jars, crates = secret_formula(start_point)print("With a starting point of:%d" % start_point)
print("We'd have %d beans, %d jars, and %d crates." % (beans, jars, crates))start_point = start_point / 10print("We can also do that this way:")
print("We'd have %d beans, %d jars, and %d crates." % secret_formula(start_point))
输出结果:
python系统学习日记 L22~L24 练习相关推荐
- python系统学习日记 L13 参数, 解包, 变量
书中代码: from sys import argvscript, first, second, third = argvprint "The script is called:" ...
- python系统学习日记 L32 循环和列表
书中代码: 这节习题,我们将使用 for循环来创建并打印一些列表.使用 for 循环之前,你需要在某个位置存放循环的结果.最好的方法是使用列表(list),顾名思义,列表就是一个按顺序存放东西的容器. ...
- python系统学习日记 L26 修正改错
书中L26是改错习题,对一段有问题的代码进行改正 书中代码: def break_words(stuff):"""This function will break up ...
- python自学流程-Python系统学习流程图,教你一步步学习python
对于刚开始接触Python的小伙伴来说,没有思路方法,不知道从何开始学习,把软件环境安装好后就不知所措了!接下来我给大家分享下多位大牛倾力打造的python系统学习流程,一个月才设计完的! Pytho ...
- 用python设计一个管理系统思路_Python大佬一个月打造的Python系统学习流程图!
对于刚开始接触Python的小伙伴来说,没有思路方法,不知道从何开始学习,把软件环境安装好后就不知所措了!接下来我给大家分享下多位大牛倾力打造的python系统学习流程,一个月才设计完的! Pytho ...
- Python系统学习流程图, 教你一步步学习python
对于刚开始接触Python的小伙伴来说,没有思路方法,不知道从何开始学习,把软件环境安装好后就不知所措了!接下来我给大家分享下多位大牛倾力打造的python系统学习流程,一个月才设计完的! Pytho ...
- python逻辑运算的一些流程图_Python大牛历时一个月打造的Python系统学习流程图,超详细!...
对于刚开始接触Python的小伙伴来说,没有思路方法,不知道从何开始学习,把软件环境安装好后就不知所措了!接下来我给大家分享下多位大牛倾力打造的python系统学习流程,一个月才设计完的! Pytho ...
- Python系统学习流程图,教你一步步学习python
对于刚开始接触Python的小伙伴来说,没有思路方法,不知道从何开始学习,把软件环境安装好后就不知所措了!接下来我给大家分享下多位大牛倾力打造的python系统学习流程,一个月才设计完的! Pytho ...
- 13位Python大牛历时一个月打造的Python系统学习流程图,超详细!
对于刚开始接触Python的小伙伴来说,没有思路方法,不知道从何开始学习,把软件环境安装好后就不知所措了!接下来我给大家分享下多位大牛倾力打造的python系统学习流程,一个月才设计完的! #Pyth ...
最新文章
- Java对象引用与对象的区别
- Vue中前端加密使用RSA加密下的JSEncrypt防止明文暴露
- 现代制造工程——考试复习01
- 单片机课程设计数字心率计_如何选购合适的PH计
- mac 安装brew及设置国内镜像
- 计算机组成原理包健百度云,计算机组成原理包健版答案
- OneProxy实现mysql读写分离
- 2021天梯决赛题目及题解(持续更新)
- 5分钟商学院-个人篇-高效能人士的思维习惯
- IT编程宝园资料分享
- Layer Emitter(图层发射器)
- 大冬与小冉的故事 !!!-----阿冬专栏
- 2022腾讯云双十一服务器价格出炉来看看便宜不
- 阿里云账号登录名修改方法(图文详解)
- android怎样传图片到mysql中
- linux查看共享内存文件,linux 共享内存
- Docker容器添加映射端口
- 北邮智能车仿真培训(四)—— 仿真原理详解
- 各类牛B电影,暑假慢慢看完
- 高斯分布-sklearn.mixture.GaussianMixture()
热门文章
- 说说你对敏捷开发的理解(架构师必刷)
- 用EXCEL表格发送物业催费短信
- K-Means聚类make_moons数据
- Unity2017.1.1f版本下发布Android项目并插入UnityAds广告方法
- Java-10.14
- 使用latexdiff做修订-windows详细步骤
- 针对内存修改的反作弊方法
- yarn : 无法加载文件 C:\Users\Admi\AppData\Roaming\npm\yarn.ps1,因为在此系统上禁止运行脚本。
- 计算机开机桌面一直转圈,Win10开机一直转圈圈怎么办?一直转圈进不去系统的解决方法...
- 林期苏曼属性标签编辑_标签打印软件如何打印一式两联标签