自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(37)
  • 收藏
  • 关注

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题37 复习各种符号

学习内容:关键字:关键字描述示例and逻辑与True and False == Falsenot逻辑非not True == Falseor逻辑或True or False == Trueaswith-as 语句的一部分with X as Y: passassert断言(确保)某东西为真assert False, “Error!...

2019-11-30 11:37:42 179

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题36设计和调试

学习内容:还是中文的文字小游戏 O(∩_∩)O哈哈~其实这个小游戏就是把事件划分成块:1、将游戏想象成几个方块,每个方块就是一个函数。2、每个函数内可以有几条分支(一般就是3条)。3、在把每个方块组装起来。其实就是化整为零。# --coding: utf-8 --def castle(): print ("屋里有一个美丽的少女正在沉睡。") print ("你是走上...

2019-11-30 09:55:11 291

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题35 分支和函数

学习内容:from sys import exitdef gold_room(): print ("This room is full of gold. How much do you take.") choice = input("> ") if "0" in choice or "1" in choice: how_much = int(c...

2019-11-27 17:38:19 383

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题34 访问列表的元素

学习内容:# --coding: utf-8 --animals = ['熊猫', '大象', '犀牛', '河马', '长颈鹿', '梅花鹿', '狮子', '老虎', '羊驼']print (animals)print ("位置1的动物是什么?")num = int(input('> '))print (f"动物是:{num}", animals[num])print ...

2019-11-27 14:13:17 222

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题33 while循环

学习内容:i = 0numbers = []while i < 6: print (f"At the top i is {i}") numbers.append(i) i = i + 1 print ("Numbers now: ", numbers) print (f"At the bottom i is {i}")print ("T...

2019-11-26 14:58:32 258

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题32 循环和列表

学习内容:the_count = [1, 2, 3, 4, 5]fruits = ['apples', 'oranges', 'pears', 'apricots']change = [1, 'pennies', 2, 'dimes', 3, 'quarters']# this first kind of for-loop goes through a listfor number i...

2019-11-26 10:41:30 317 1

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题31 做出决定

学习内容:print ("""You enter a dark room with two doors.Do you go through door #1 or door #2?""")door = input("> ")if door == "1": print ("There's a giant bear here eating a cheese cake.") ...

2019-11-25 17:38:22 229

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题30 else和if

学习内容:people = 30cars = 40trucks = 15if cars > people: print ("We should take the cars.")elif cars < people: print ("We should not take the cars.")else: print ("We can't decid...

2019-11-25 13:30:42 156

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题29 if语句

学习内容:people = 20cats = 30dogs = 15if people < cats: print ("Too mant cats! The world is doomed!")if people >cats: print ("Not many cats! The world is saved!")if people < dog...

2019-11-25 11:44:07 122

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题28 布尔表达式练习

学习内容:书中个别拼写有问题,运行时会报错True and True False and False 1 == 1 and 2 == 1 "test" == "test" 1 == 1 or 2 != 1 True and 1 == 1 False and 0 != 0 True or 1 == 1 "test" == "testing" 1 != 0 and 2 ==...

2019-11-25 10:19:00 170

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题27 记住逻辑关系

学习内容:1. 逻辑术语:• and: 与• or: 或• not: 非• !=: 不等于• ==: 等于• >=: 大于等于• <=: 小于等于• True:真• False:假2.真值表① not:很好理解not真假not FalseTruenot TrueFalse② or:只要有True,就是True。任何包含Tru...

2019-11-23 17:40:35 106

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题26 恭喜你,现在可以考试了!

学习内容:原始代码错误较多print("How old are you?", end=' ')age = input()print("How tall are you?", end=' ')print("How much do you weigh?", end=' 'weight = input()print(f"So, you're {age} old, {height} tal...

2019-11-23 17:10:20 365

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题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(wor...

2019-11-23 16:05:21 359

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题24 更多的练习

学习内容:print ("Let's practice everything.")print ('You\'d need to know \'bout escapes with \\ that do:')print ('\n newlines and \t tabs.')poem = """\tThe lovely worldwith logic so firmly planted...

2019-11-23 14:12:52 255

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题23 字符串、字节串和字符编码

学习内容:import sysscript, encoding, error = sys.argvdef main(language_file, encoding, errors): line = language_file.readline() if line: print_line(line, encoding, errors) re...

2019-11-22 16:30:29 610 3

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题22 到现在为止你学到了什么

学习内容:def add(a, b): print (f"ADDING {a} + {b}") return a + bdef subtract(a, b): print (f"SUBTRACTING {a} - {b}") return a - bdef multiply(a, b): print (f"MULTIPLYING {a} * {b}...

2019-11-22 13:16:10 203

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题20 函数和文件

学习内容:from sys import argvscript, input_file = argvdef print_all(f): print (f.read())def rewind(f): f.seek(0)def print_a_line(line_count, f): print (line_count, f.readline())curr...

2019-11-21 13:03:57 247

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题19 函数和变量

学习内容:def cheese_and_crackers(cheese_count, boxes_of_crackers): print (f"You have {cheese_count} cheeses!") print (f"You have {boxes_of_crackers} boxes_of_crackers!") print ("Man that's en...

2019-11-20 14:08:07 192

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题18 命名、变量、代码和函数

学习内容:# this one is like your scripts with argvdef print_two(*args): arg1, arg2 = args print (f"arg1: {arg1}, arg2: {arg2}")# ok, that *args is actually pointless,we can just do thisdef pr...

2019-11-20 13:05:04 180

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题17 更多文件操作

学习内容:from sys import argvfrom os.path import existsscript, from_file, to_file = argvprint (f"Copying from {from_file} to {to_file}")# we could do these two on one line, how?in_file = open(fro...

2019-11-20 11:13:24 176

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题16 读写文件

学习内容:运行结果:知识点:目前需记住的命令(函数/方法)close():关闭文件。与编辑器中的“文件”→“保存”是一个意思。read():读取文件的内容。可以把结果赋给一个变量。readline():只读取文本文件中的一行。truncate():清空文件,需小心使用该命令。write(‘stuff’):将’stuff’写入文件。write需要接收一个字符串作为参数,将该字符串...

2019-11-19 16:34:56 390 1

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题15 读取文件

学习内容:解析:1~3行使用argv来获取文件名5行 打开文件对象8行是调用这个txt9行是执行读这个txtfrom sys import argvscript, filename = argvtxt = open(filename)print (f"Here's your file {filename}:")print (txt.read())print ("T...

2019-11-15 17:51:36 312

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题14 提示和传递

学习内容:本文中prompt:将输入提示符 ‘>’ 设置为变量prompt,这样不用每次在input的时候输入 ‘>’from sys import argvscript, user_name = argvprompt = '> 'print (f"Hi {user_name}, I'm the {script} script.")print ("I'd like...

2019-11-15 15:24:59 205

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题13 参数、解包和变量

学习内容:from sys import argv#read the WYSS section for how to run thisscript, first, second, third = argvprint ("The acript is called:", script)print ("Your first variable is:", first)print ("Your...

2019-11-15 14:47:14 303

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题12 提示别人

学习内容:age = input("How old are you? ")height = input("How tall are you? ")weight = input("How much do you weight? ")print (f"So, you're {age} old, {height} tall and {weight} heavy.")运行结果:知识点:...

2019-11-14 18:01:31 162

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题11 提问

学习内容:print ("How old are you?", end=' ')age = input()print ("How tall are you?", end=' ')height = input()print ("How much do you weigh?", end= ' ')weight = input('> ')print (f"So, you're {a...

2019-11-14 17:50:07 135

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题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* Cat food\t* Fishies\t*Catnip\n\t* Grass"""print (t...

2019-11-14 16:19:49 177

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题9 打印,打印,打印

学习内容:# Here's some new strange stuff, remember type it exactly.days = "Mon Tue Wed Thu Fri Sat Sun"months = "Jan\nFen\nMar\nApr\nMay\nJun\nJul\nAug"print ("Here sre the days:", days)print ("Her...

2019-11-14 15:09:20 183

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题8 打印,打印

学习内容:formatter = "{} {} {} {}"print (formatter.format(1, 2, 3, 4))print (formatter.format("one", "two", "three", "four"))print (formatter.format(True, False, False, True))print (formatter.format...

2019-11-14 13:35:21 161

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题7 更多的打印

学习内容:print ("Mary had a little lamb.")print ("Its fleece was white as {}.".format('snow'))print ("And everywhere that Mary went.")print ("." * 10) # what'd that do?end1 = "C"end2 = "h"end3 = "...

2019-11-14 13:18:37 191

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题6 字符串和文本

学习内容:types_of_people = 10x = f"There are {types_of_people} types of people."binary = "binary"do_not = "don't"y = f"Those who know {binary} and those who {do_not}."print (x)print (y)print (f"...

2019-11-14 12:51:47 360

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题5 更多的变量和打印

学习内容:运行结果:知识点:

2019-11-14 12:23:35 137

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题4 变量和命名

学习内容:cars = 100space_in_a_car = 4.0drivers = 30passengers = 90cars_not_driven = cars - driverscars_driven = driverscarpool_capacity = cars_driven * space_in_a_caraverage_passengers_per_car = p...

2019-11-13 16:54:51 217

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题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 ...

2019-11-13 15:22:18 152

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题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 ig # You can also use a...

2019-11-13 14:05:20 360

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-习题1 第一个程序

#《笨办法学Python3-Learn Python 3 the HARD WAY》-习题1学习内容:print ("Hello World!")print ("Hello Again")print ("I like typing this."))print ("This is fun.")print ('Yay! Printing.')print ("I'd much rather...

2019-11-13 13:52:56 331 1

原创 《笨办法学python3-Learn Python 3 the HARD WAY》-前期准备(Windows PowerShell)

《笨办法学Python3-Learn Python 3 the HARD WAY》-前期准备(Windows PowerShell)**PowerShell 基础操作** 目前用到的,后期再补充。PowerShell 基础操作目前用到的,后期再补充。查看当前所在位置:pwd显示当前目录下的内容:ls/dir 若要看一个路径下的目录:ls xxx以树状形状显示目录结构:treetr...

2019-11-13 13:18:08 208

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除