《 笨方法学 Python 》- Python3
文章平均质量分 85
Yinz__
这个作者很懒,什么都没留下…
展开
-
《 笨方法学 Python 》_ 习题 27 - 31
习题 27:记住逻辑关系 逻辑术语 and 与 or 或 not 非 != 不等于 == 等于 >= 大于等于 <= 小于等于 Tru...原创 2018-06-02 21:28:36 · 318 阅读 · 1 评论 -
《 笨方法学 Python 》_ 习题 24 - 25
习题 24:更多练习print("Let's practice everything.")print('You\'d need to know \'bout escapes with \\ that do \n newlines and \t tabs.')poem = """\tThe lovely worldwith logic so firmly plantedcannot di...原创 2018-06-02 11:24:28 · 402 阅读 · 0 评论 -
《 笨方法学 Python 》_ 习题 18 - 23
习题 18:命名、变量、代码和函数# this one is like your scripts with argvdef print_two(*args): arg1, arg2 = args print("arg1: %r, arg2: %r" % (arg1, arg2)) # ok, that *argv is actually pointless, we ca...原创 2018-06-01 22:42:01 · 816 阅读 · 0 评论 -
《 笨方法学 Python 》_ 习题 15 - 17
习题 15:读取文件这个习题涉及写两个文件,一个是 ex15.py 文件,另外一个是 ex15_sample.txt,是供你的脚本读取的文本文件。下面是该文本文件的内容。This is stuff I typed into a file.It is really cool stuff.Lots and lots of fun to have in here.from sys import argv...原创 2018-06-01 17:10:36 · 734 阅读 · 0 评论 -
《 笨方法学 Python 》_ 习题 13 - 14
习题 13:参数、解包和变量一个可以接受参数的脚本from sys import argvscript, first, second, third = argvprint("The script is called:", script)print("Your first variable is:", first)print("Your second variable is:", sec...原创 2018-05-31 21:38:05 · 732 阅读 · 0 评论 -
《 笨方法学 Python 》_ 习题 10 - 12
习题 10:那是什么# 使用反斜杠(\)可以将难打印出来的字符放到字符串tabby_cat = "\tI'm tabbed in."persian_cat = "I'm split\non a line."backslash_cat = "I'm \\ a \\ cat."# 可以在一组三引号之间放入任意多行的文字fat_cat = """I'll do a list:\t* Ca...原创 2018-05-31 17:43:16 · 315 阅读 · 0 评论 -
《 笨方法学 Python 》_ 习题 6 - 9
习题 6:字符串和文本x = "There are %d types of people." % 10binary = "binary"do_not = "don't"# 如果在字符串中通过格式化字符放入多个变量,需要将变量放到()中,变量之间用逗号隔开y = "Those who know %s and those who is %s." % (binary, do_not)pri...原创 2018-05-31 16:17:51 · 706 阅读 · 0 评论 -
《 笨方法学 Python 》_ 习题 2 - 5
习题 2:注释和 # 号# A comment, this is so you can read your program later.# Anything after the # is ignored by python.print("I could have code like this.") # and the comment after is ignored# You can a...原创 2018-05-30 21:11:06 · 432 阅读 · 0 评论 -
《 笨方法学 Python 》_ 习题 1
习题 1:第一个程序print("Hello World!")print("Hello Again")print("I like typing this.")print("This is fun.")print("Yay! Printing.")print("I'd much rather you 'not'.")print('I "said" do not原创 2018-05-30 19:41:03 · 308 阅读 · 0 评论 -
《 笨方法学 Python 》_ 目录
《 笨方法学 Python 》(第 3 版)书中代码是 Python 2 版本,但 Python 核心团队计划在 2020 年停止支持 Python 2,Python 3 大势所趋。本着学习 Python 3 的目的,用 Python 3 完成本书的习题。作者 Zed A. Shaw 也写了 Python 3 版本:Learn Python the Hard Way人生苦短,我用 Python。...原创 2018-05-30 19:03:17 · 1120 阅读 · 0 评论 -
《 笨方法学 Python 》_ 习题 44
习题 44:继承与合成原创 2018-06-06 09:47:33 · 631 阅读 · 1 评论 -
《 笨方法学 Python 》_ 习题 43
习题 43:基本的面向对象分析和设计类的层次结构图* Map - next_scene - opening_scene* Engine - play* Scene - enter * Death * Center Corridor * Laser Weapon Armory * The Bridge * Escape ...原创 2018-06-05 20:19:09 · 1038 阅读 · 0 评论 -
《 笨方法学 Python 》_ 习题 40 - 42
习题 40:模块、类和对象原创 2018-06-04 19:36:47 · 1473 阅读 · 2 评论 -
《 笨方法学 Python 》_ 习题 38 - 39
习题 38:列表的操作ten_things = "Apples Oranges Crows Telephone Light Sugar"print("Wait there's not 10 things in that list, let's fix that.")stuff = ten_things.split(' ')more_stuff = ["Day", "Night", "So...原创 2018-06-03 21:18:37 · 788 阅读 · 0 评论 -
《 笨方法学 Python 》_ 习题 35 - 37
习题 35:分支和函数from sys import exitdef gold_room(): print("This room if full of gold. How much do you take?") next = input("> ") if "0" in next or "1" in next: how_much = int...原创 2018-06-03 12:50:47 · 400 阅读 · 0 评论 -
《 笨方法学 Python 》_ 习题 32 - 34
习题 31:循环和列表the_coount = [1, 2, 3, 4]fruits = ['apples', 'oranges', 'pears', 'apricots']change = [1, 'pennies', 2, 'dimes', 3, 'quarters']# this first kind of for-loop goes through a listfor numbe...原创 2018-06-03 09:45:44 · 332 阅读 · 0 评论 -
《 笨方法学 Python 》_ 习题 26
习题 26 :恭喜你,现在可以考试了!这个习题的目的不是写程序,而是修正现有的程序,你需要访问网站 https://learnpythonthehardway.org/exercise26.txt,从那里把代码复制粘贴过来,命名为 ex26.py 。def break_words(stuff): """This function will break up words for us."""...原创 2018-06-02 12:51:23 · 964 阅读 · 0 评论