笨办法学python
来自笨办法学习python喜提
AllanRobinLukeman
云计算IaaS运维,Linux,虚拟化,Openstack,数据库,考证
展开
-
笨办法学python ex30
前一习题中你写了一些 “if 语句(if-statements)”,并且试图猜出它们是什么,以 及实现的是什么功能。在你继续学习之前,我给你解释一下上一节的加分习题的答案。上一节的加分习题你做过了吧,有没有? 你认为 if 对于它下一行的代码做了什么? If 语句为代码创建了一个所谓的“分支”, 就跟 RPG 游戏中的情节分支一样。if 语句告诉你的脚本: “如果这个布尔表达式为 真,就运行接下来的代码,否则就跳过这一段。” 为什么 if 语句的下一行需要 4 个空格的缩进? 行尾的冒号的作用是告诉 P原创 2020-09-10 16:09:43 · 113 阅读 · 0 评论 -
笨办法学python ex24
你离这本书第一部分的结尾已经不远了,你应该已经具备了足够的 Python 基础知识,可以继续学习一些编程的原理了,但你应该做更多的练习。这个练习的内容比较长,它的目的是锻炼你的毅力,下一个习题也差不多是这样的,好好完成它们,做到完全正确,记得仔细检查。 print("Let's practice everything.") print('You\'d need to know \'bout escape with \\ that do:') #用单引号时,单引号内的标点符号需要转义包含\ print('原创 2020-09-10 15:21:40 · 112 阅读 · 0 评论 -
笨办法学python ex22
这节以及下一节的习题中不会有任何代码,所以也不会有习题答案或者加分习题。其实这节习题可以说是一个巨型的加分习题。我将让你完成一个表格,让你回顾你到现在学到的所有东西。 首先,回到你的每一个习题的脚本里,把你碰到的每一个词和每一个符号(symbol,character的别名)写下来。确保你的符号列表是完整的。 下一步,在每一个关键词和字符后面写出它的名字,并且说明它的作用。如果你在书里找不到符号的名字,就上网找一下。如果你不知道某个关键字或者符号的作用,就回到用到该字符的章节通读一下,并且在脚本中测试一下原创 2020-09-10 15:09:12 · 162 阅读 · 0 评论 -
笨办法学python ex24
print("Let's practice everything.") print('You\'d need to know \'bout escape with \\ that do:') #用单引号时,单引号内的标点符号需要转义,包含\ print('\n newlines and \t tables.') #\n后 \t制表符增加空出4个字节 poem = """ \tThe lovely world with logic so firmly planted cannot discern \n.原创 2020-08-18 15:40:56 · 141 阅读 · 0 评论 -
笨办法学python ex25
习题25 代码如下: def break_words(stuff): """This function will break up words for us.""" words = stuff.split(' ') return words def sort_words(words): """Sorts the words.""" return sorted(words) def print_first_word(words): """Prints t原创 2020-08-17 17:23:07 · 322 阅读 · 0 评论 -
笨办法学python3 ex6
习题6 #f"{}"格式化 "f-string" type_of_people = 10 x = f"There are {type_of_people} types of people." binary = "binary" do_not = "don't" y = f"Those who know {binary} and those who {do_not}." # 注意:f"{}"字符串的形式,我把变量放置到{}此位置 print(x) print(y) print(f"I said: {原创 2020-08-13 17:38:49 · 186 阅读 · 0 评论 -
笨办法学python3 ex5
习题5 my_name = 'Zed A. Shaw' my_age = 35 # not a lie my_height = 74 # inches my_weight = 180 # lbs my_eyes = 'Blue' my_teeth = 'White' my_hair = 'Brown' print(f"Let's talk about {my_name}.") print(f"He's {my_height} inches tall.") print(f"He's {my_weight原创 2020-08-13 17:10:26 · 196 阅读 · 0 评论 -
笨办法学习python3 ex4
习题4 cars = 100 space_in_a_car = 4.0 drivers = 30 passengers = 90 cars_not_driven = cars - drivers cars_driven = drivers carpool_capacity = cars_driven * space_in_a_car average_passemgers_per_car = passengers / cars_driven print ("There are", cars, "car.原创 2020-08-12 14:55:45 · 171 阅读 · 0 评论 -
笨办法学习python3 ex3
习题3 认识代码块中数学运算,以及布尔值 print("I will now count my chickens:") print("Hens", 25 + 30 / 6) print("Roosters", 100 - 25 * 3 % 4) print("Now I will count the eggs:") print( 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6) print("Is it true that 3 + 2 < 5 - 7?") pri.原创 2020-08-12 14:43:18 · 201 阅读 · 0 评论 -
笨办法学python3 ex2
习题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 also use a comment to "disable" or comment out code. #原创 2020-08-12 14:28:54 · 150 阅读 · 0 评论 -
笨办法学python3 ex1
习题1 print("Hello World!") print("Hello Again") print("I like typing this.") print("I'd much rathar you 'not'") print('Yay! Printing') print('I "said" do not touch this.') 执行输出: D:\pycharmproject\untitled\venv\Scripts\python.exe D:/pycharmproject/unti.原创 2020-08-12 14:24:13 · 179 阅读 · 0 评论