笨办法学Python-----习题25_更多更多的练习

在这里插入图片描述

import ex25
sentence = "All good things come to those who wait."
words = ex25.break_words(sentence)
words

ex25.print_first_word(words)
ex25.print_last_word(words)
words

ex25.print_first_word(sorted_words)
ex25.print_last_word(sorted_words)
sorted_words

sorted_words = ex25.sort_sentence(sentence)
sorted_words
ex25.print_first_and_last(sentence)
ex25.print_first_and_last_sorted(sentence)

在这里插入图片描述

  看来这一节的重点在于模块的使用,还是极为重要的。

巩固练习

1、研究对模块ex25函数中的调用

break_words:使用split方法把一个句子字符串分隔个单个得单词放入列表
sort_words:对列表中的元素按字母顺序排序
print_first_word:使用pop(0)方法弹出列表中第一个元素
print_last_word:使用pop(-1)方法弹出列表最后一个元素
sort_sentence:结合break_words和sort_words
print_first_and_last:调用break_words和print_first_word、print_last_word
print_first_and_last_sorted:调用sort_sentence和print_first_word、print_last_word

2、得到模块的帮助文档

在这里插入图片描述

  注意,使用help(模块)得到模块的帮助文档的时候,是在python环境中的,而不是在shell中直接help。帮助文档就是定义函数或者类的三引号之间的字符串,称为文档注释。导入文件的时候,不需要.py的后缀。

3、研究几种导入模块和方法的途径

  • 从一个模块导入多个类:from module import class1,class2…
  • 导入整个模块:import car
  • 访问类:module.class 导入模块所有类(不推荐使用):from module import *
  • 模块之间的相互依赖也采取同样的导入方法
    在这里插入图片描述

学习感悟:终于完成了这俩麻烦的题目,不过也完全地把前面地内容复习了一遍,根据肖哥的标准,目前的学习结果还是比较好的,接下来就考试一波检验一下!

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值