python版本:3      若有错误,敬请指出 模块名称:测试.py

我的是版本3,表示很坑爹,需要宝宝把所有的print加上括号 =0= >_<

#加分习题26
import 加分习题25#自己加上的
def break_words(stuff):"""This function will break up words for us."""words = stuff.split(' ')return wordsdef sort_words(words):"""Sorts the words."""return sorted(words)def print_first_word(words):#原代码缺少引号"""Prints the first word after popping it off."""word = words.pop(0)#原代码poop改为popprint(word)def print_last_word(words):"""Prints the last word after popping it off."""word = words.pop(-1)#原代码缺少括号print(word)def sort_sentence(sentence):"""Takes in a full sentence and returns the sorted words."""words = break_words(sentence)return sort_words(words)def print_first_and_last(sentence):"""Prints the first and last words of the sentence."""words = break_words(sentence)print_first_word(words)print_last_word(words)def print_first_and_last_sorted(sentence):"""Sorts the words then prints the first and last one."""words = sort_sentence(sentence)print_first_word(words)print_last_word(words)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 explantion
\n\t\twhere there is none.
"""print("--------------")
print(poem)
print("--------------")five = 10 - 2 + 3 - 5
print("This should be five: %s" % five)def secret_formula(started):jelly_beans = started * 500jars = jelly_beans / 1000#原代码除号写错crates = jars / 100return jelly_beans, jars, cratesstart_point = 10000
beans, jars, crates = secret_formula(start_point)#原代码删除一个等号,start-point改为start_pointprint("With a starting point of: %d" % start_point)
print("We'd have %d jeans, %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 crabapples." % secret_formula(start_point))#原代码缺少括号
#原代码start_pont改为start_pointsentence = "All god\tthings come to those who weight."words =加分习题25.break_words(sentence)#我的模块名称为加分习题25,开头加上import模块名称
#又或者可以删掉(加分习题25.)
sorted_words = 加分习题25.sort_words(words)print_first_word(words)
print_last_word(words)
print_first_word(sorted_words)#删除小圆点
print_last_word(sorted_words)
sorted_words = 加分习题25.sort_sentence(sentence)
print(sorted_words)#原代码print拼写错误print_first_and_last(sentence)#原代码print_irst_and_last(sentence)改为print_first_and_last(sentence)print_first_and_last_sorted(sentence)#原代码缩进错误
#原代码print_first_a_last_sorted(senence)改为print_first_and_last_sorted(sentence)

运行截图:

笨办法学python加分习题26相关推荐

  1. 《笨办法学Python》——习题3

    文章目录 基本习题 1. 完成基本习题 加分习题 1. 使用#在代码每一行的前一行为自己写一个注解,说明一下这一行 2. 记得开始时的 <练习 0> 吧?用里边的方法把 Python 运行 ...

  2. 《笨办法学Python》——习题5

    文章目录 基本习题 1. 完成基本习题 加分习题 1. 修改所有的变量名字,把它们前面的"my_"去掉.确认将每一个地方的都改掉,不只是你使用"="赋值过的地方 ...

  3. python 笔记 一次失败的例子 《笨办法学Python》习题36 ——1.19

    习题 36: 设计和调试 自我感觉: •墨水太少,只写了一半 •好中二 •low~~~~ ex36.py # -*- coding:UTF-8 -*- ###测试python输出中文是否乱码 impo ...

  4. python hexdump_笨办法学 Python · 续 练习 26:`hexdump`

    练习 26:hexdump 译者:飞龙 自豪地采用谷歌翻译 你已经用xargs完成了热身,现在正在代码/审计的循环中.你现在将尝试以"测试优先"方式完成下一个挑战.这就是,你编写测 ...

  5. python转义例题_笨办法学Python记录--习题37 异常,lambda,yield,转义序列

    为什么使用异常 错误处理.事件通知.特殊情况处理.退出时的行为.不正常的程序流程. 简单的示例 在没有任何定义x变量的时候: print x print 1 将会抛出NameError异常: Name ...

  6. 笨办法学Python 3 习题4

    [交作业啦] ex4.py # 变量cars指代100, cars的数量是100 cars = 100 # 变量space_in_a_car指代4.0,一辆车上有4.0个座位 #space_in_a_ ...

  7. python 笔记 练习、加深记忆 《笨办法学Python》习题24 ——12.29

    习题 24:  更多练习 目标与感悟: •熟悉语法 •衔接.叠加的使用 •要有美学眼光 •码代码不能懒,不要复制,要手打,当然,可以使用notepad++的脚本来查异 ex24.py #-*-codi ...

  8. python 笔记 分支和函数《笨办法学Python》习题35 ——1.17

    习题 35:  分支和函数 知识点总结: • 本次做的是利用循环.判定做的一个小游戏 •fromsys import exit     #向sys模块借一个exit函数用来退出程序 •exit(0), ...

  9. 从零开始学数据分析之——《笨办法学Python》(习题0-10)

    写在前面 三十而立之年,开始自学数据分析,工作比较清闲,现发帖记录自己的数据分析之路,数据分析要学很多的东西,经过多月的摸索,目前分两个方面开始学习: ·知识方面:数学为王,拿起书本,重学<概率 ...

最新文章

  1. 使用Wasserstein距离鉴别器的无监督图对齐
  2. Windows Form中的Grid Control
  3. 《Atlas基础教程》勘误(持续更新)
  4. Jerry答网友提问:SAP CRM WebClient UI里的EXT,STRUCT等含义
  5. python3输入输出_Python3 输入和输出
  6. 我10年来的学习和生活
  7. [Vue.js] 基础 -- 过滤器(格式化时间)
  8. c语言 syn扫描,syn flooder*** (C语言)
  9. 简单的签到代码_签到功能,用 MySQL 还是 Redis ?
  10. IDEA中控制台中文乱码问题
  11. 内存管理的概念及作用
  12. 随机森林原始论文_【论文笔记】韩家炜团队AutoPhrase:从大量文本库中 自动挖掘短语...
  13. 第四讲 系统建模方法
  14. 谈谈蛋疼的问题:里式替换原则:正方形是长方形吗?
  15. 前端开发工程师的前传
  16. php a标签加nofollow,Z-Blog给文章所有的站外a链接添加nofollow的方法
  17. Gradle 实现 Android 多渠道定制化打包
  18. Windows NT 简介
  19. jquery 遍历java对象_jquery中object对象循环遍历的方法
  20. 基于现有电脑和手机,“掌上看家”帮你零投入远程照料家中儿童与老人

热门文章

  1. 条件概率/全概率/贝叶斯公式
  2. 人人保险篇|用“保险”开启了“财富自由”的小目标
  3. 牵手新潮传媒,独角兽们彰显社区“狼群效应”
  4. Windows共享文件夹设置
  5. Netty简单聊天实例
  6. 深入解析Mac OS X iOS操作系统
  7. Linux系统下Sen2Cor对Sentinel哨兵2号遥感数据预处理(辐射定标和大气校正)Sen2Cor下载,使用
  8. 重庆北大青鸟解放碑校区J11班 勇往直前队 [OA智能办公系统]
  9. Hadoop 2.6.0 完全分布式部署安装
  10. 【数据分析】如何量化时间序列之间的相似性?