目录

  • 逻辑控制与循环
    • 逻辑判断 -- `True` / `Flase`
    • 比较运算
      • 比较运算的两个小问题
      • 布尔型数据的比较
    • 成员运算符`in`和身份运算符`is`
    • 布尔运算符:`not`, `and`, `or`
  • 条件控制
    • 简单条件判断
    • 多条件判断
  • 循环
    • for 循环
      • 嵌套循环
    • while 循环
    • 练习题
  • 综合练习
  • 练习题

逻辑控制与循环

逻辑判断 – True / Flase

上面的TrueFalse称为布尔型数据,凡能够产生一个布尔值的表达式成为布尔表达式,通过以下布尔表达式体会布尔值的用法。

print(1 > 2)
False
print(1 < 2 < 3)
True
print(42 != '42')
True
print('Name' == 'name')
False
print('M' in 'Magic')
True
number = 12
print(number is 12)
True

比较运算

比较运算符: ==!=><<=>=
除简单、直接的比较外,比较运算还支持更丰富的表达方式

# 多条件比较
middle = 5
1 < middle < 10
True
# 变量的比较
two = 1 + 1
three = 1 +2
two < three
True
# 字符串的比较,即比较两个字符串是否完全一致,注:python严格区分大小写
'Eddie Van Helen' == 'eddie van helen'
False
# 两个函数结果的比较
abs(-10) > len('length of this word')
False

比较运算的两个小问题

  1. 不同类型的对象不能使用"<, >, <=, >=“比较,但可以使用”==“和”!="
42 > 'the answer' # 不能比较,报错
---------------------------------------------------------------------------TypeError                                 Traceback (most recent call last)<ipython-input-11-d93c2e59925c> in <module>
----> 1 42 > 'the answer' # 不能比较,报错TypeError: '>' not supported between instances of 'int' and 'str'
42 == 'the answer' # 可以比较
False
42 != 'the answer' # 可以比较
True
  1. 虽然浮点型和整型是不同类型,但是不影响比较运算
5.0 == 5
True
3.0 > 1
True

布尔型数据的比较

True > False
True
True + False > False + False
True

TrueFalse对于计算机就等价于10,所以上面两个表达式等价于:

1 > 0
True
1 + 0 > 0 + 0
True

另注:1 <> 3 等价于 1 != 3,写法不同而已

在python中任何对象的都可判断其布尔值,除了0None,和所有空的序列与集合(列表、字典、集合)的布尔值为Flase之外,其他都为True可以使用bool()函数进行判别

bool(0)
False
bool([])
False
bool('')
False
bool(False)
False
bool(None)
False

成员运算符in和身份运算符is

成员运算符和身份运算符的关键词是inis

  • in 的含义是:测试前者是否存在于in后面的集合中,与not in对应;
  • is是进行身份对比的,其含义是:经过is对比,两个变量一致时则返回True,否则返回False,与is not对应;
  • innot in是表示归属型关系的运算,isnot is是表示身份鉴别的运算

预备知识:简单了解一下一个简单的集合类型,列表的概念

  • 列表是一个简单、实用的集合类型
  • 字符串、浮点型、整型、布尔型数据、变量和另一个列表都可以储存在列表中
  • 和创建变量一样,创建列表需要先给它起一个名字
  • 列表可以是空的,也可以是非空的
# 空列表
album = []
# 非空列表
album = ['Black Star', 'David Bowie', 25, True]
print(album)
['Black Star', 'David Bowie', 25, True]

当列表创建完成后,想再次往里添加内容时,使用列表的方法:append ,向列表中添加新元素。使用这种方式添加的元素自动排列到列表尾部

album.append('new song')
album
['Black Star', 'David Bowie', 25, True, 'new song']

列表的索引,与字符串的索引类似

# 打印列表中的第一个元素和最后一个元素
print(album[0], album[-1])
Black Star new song

进入正题

  • 使用in测试字符串 ‘Black Star’ 是否在列表album中,如果存在返回True, 否则返回False
print('Black Star' in album)
print("Black Star" not in album)
True
False
  • 使用is测试the_Eddiename两个变量是否相等,如果相等返回True, 否则返回False
the_Eddie = 'Eddie'
name = 'Eddie'
print(the_Eddie == name)
print(the_Eddie is name)
print(the_Eddie is not name)
True
True
False

布尔运算符:not, and, or

与逻辑运算符相对应,not是取非,and是与运算,or是或运算

运算符 描述
not x 如果 x 是 True,则返回 False,否则返回 True
x and y and 表示“并且”,如果 x 和 y 都是 True,则返回True;如果 x 和 y 有一个是 False,则返回False
x or y or 表示“或者”,如果 x 或 y 其中有一个是 True,则返回True;如果 x 和 y 都是False,则返回False
# 非运算
print(not bool(None))
True

andor经常用于处理复合条件,类似于1 < n < 3, 也就是两个条件同时满足

print(1 < 3 and 2 < 5)
print(1 < 3 and 2 > 5)
print(1 < 3 or 2 > 5)
print(1 > 3 or 2 > 5)
True
False
True
False

条件控制

简单条件判断

# 伪代码
if condition:do something 1
else:do something 2

if, else关键字;condition成立的条件;
if...else结构的作用:如果if后条件成立,即返回True则做do something 1, 否则做else后的do something 2

# 例子:账号登录
# 定义函数
def account_login():password = input('Password:')if password == '12345':print('Login Success!')else:print('Wrong password or invalid input!')account_login() # 如果输入错误,则再次运行函数,让用户重新输入;如果不加这句就只输入一次,然后打印# 调用函数
account_login()
Password: 666
Wrong password or invalid input!
Password: 12345
Login Success!

如果if后的布尔表达式过长或者难于理解,可以采用给变量赋值的方法来储存布尔表达式返回的布尔值,所以更清晰的写法:

# 定义函数
def account_login():password = input('Password:')password_correct = password == '12345' # 这里给变量赋值以便更好地理解 if 后 condition 的含义if password_correct:print('Login Success!')else:print('Wrong password or invalid input!')account_login()# 调用函数
account_login()
Password: 666
Wrong password or invalid input!
Password: 12345
Login Success!

多条件判断

  • ifelse之间加上elif,用法和if一致,条件判断依次进行,若都不成立则运行else对应的语句
  • elif可以有无限多个
  • 也可以不用else,都用elif
# 伪代码
if condition_1:do something 1
elif condition_2:do something 2
else:do something 3

给前面的函数增加一个密码重置的功能

# 创建一个列表,用于储存用户的密码、初始密码和其他数据(对实际数据库进行简化模拟)
password_list = ['*#*#', '12345']# 定义函数
def account_login():password = input('Please input your password:')# 当用户输入密码等于列表中最后一个元素(即用户设定的密码),登录成功password_correct = password == password_list[-1]# 当用户输入密码等于列表中第一个元素时(即重置密码“口令”)触发密码变更,并将变更密码储存至列表的最后一个,成为用户新密码password_reset = password == password_list[0]if password_correct: # 密码正确print('Login Success!')elif password_reset: # 密码重置new_password = input('Please enter your new password:')password_list.append(new_password)# 注意上面这句不要漏了,因为密码列表没有变,所以不添加的话密码还是'12345',相当于没有改密码# 所以需要将新密码添加至password_list中,append默认添加至最后一位print('Your password has changed successfully!')account_login()else: # 若上述情况均不成立,则打印错误提示,并再次运行函数,让用户继续输入密码print('Wrong password or invalid input!')account_login()# 调用函数
account_login()
Please input your password: 666
Wrong password or invalid input!
Please input your password: *#*#
Please enter your new password: 666
Your password has changed successfully!
Please input your password: 666
Login Success!

再次强调:

  1. 所有关键字后面的冒号一定不能少,否则会报语法错误;
  2. 一定要注意缩进,相同缩进的代码块完成的是一个层级的事儿,有点像编辑文档时不同层级的任务列表

循环

for 循环

for循环所做的事情概括来讲就是:对集合:iterable中的每一个元素item,做do something

# 伪代码
for item in iterable:do something

for, in是关键字;item是指集合中的每一个元素;iterable是指可以连续地提供每一个迭代元素的对象,是一个集合形态的对象;
do something是指迭代过程中每一个元素需要做的事;
再次强调:注意冒号和缩进

小例子:打印出'hello world'这个字符串中的每一个字符

for every_letter in 'Hello world':print(every_letter)
H
e
l
l
ow
o
r
l
d

再来一个小例子,继续理解for循环

for num in range(1,11):print(str(num) + '+1 =', num + 1)# 打印的另一种写法# print(num, '+1=', num+1)
1+1 = 2
2+1 = 3
3+1 = 4
4+1 = 5
5+1 = 6
6+1 = 7
7+1 = 8
8+1 = 9
9+1 = 10
10+1 = 11

进阶小例子:将forif组合起来用
歌曲列表中有三首歌分别是“Holy Diver, Thunderstruck, Rebel Rebel”,当播放到每首歌曲时,分别显示对应歌手的名字“Dio, AC/DC, David Bowie”
实现过程:将SongsList列表中的每一个元素依次取出,分别与三个条件比较,成立则输出对应的内容。

SongsList = ['Holy Diver', 'Thunderstruck', 'Rebel Rebel']
for song in SongsList:if song == 'Holy Diver':print(song, '- Dio')elif song == 'Thunderstruck':print(song, '- AC/DC')elif song == 'Rebel Rebel':print(song, '- David Bowie')
Holy Diver - Dio
Thunderstruck - AC/DC
Rebel Rebel - David Bowie

嵌套循环

小例子:九九乘法表

for i in range(1, 10):for j in range(1, 10):print('{} × {} = {}'.format(i, j, i*j))
1 × 1 = 1
1 × 2 = 2
1 × 3 = 3
1 × 4 = 4
1 × 5 = 5
1 × 6 = 6
1 × 7 = 7
1 × 8 = 8
1 × 9 = 9
2 × 1 = 2
2 × 2 = 4
2 × 3 = 6
2 × 4 = 8
2 × 5 = 10
2 × 6 = 12
2 × 7 = 14
2 × 8 = 16
2 × 9 = 18
3 × 1 = 3
3 × 2 = 6
3 × 3 = 9
3 × 4 = 12
3 × 5 = 15
3 × 6 = 18
3 × 7 = 21
3 × 8 = 24
3 × 9 = 27
4 × 1 = 4
4 × 2 = 8
4 × 3 = 12
4 × 4 = 16
4 × 5 = 20
4 × 6 = 24
4 × 7 = 28
4 × 8 = 32
4 × 9 = 36
5 × 1 = 5
5 × 2 = 10
5 × 3 = 15
5 × 4 = 20
5 × 5 = 25
5 × 6 = 30
5 × 7 = 35
5 × 8 = 40
5 × 9 = 45
6 × 1 = 6
6 × 2 = 12
6 × 3 = 18
6 × 4 = 24
6 × 5 = 30
6 × 6 = 36
6 × 7 = 42
6 × 8 = 48
6 × 9 = 54
7 × 1 = 7
7 × 2 = 14
7 × 3 = 21
7 × 4 = 28
7 × 5 = 35
7 × 6 = 42
7 × 7 = 49
7 × 8 = 56
7 × 9 = 63
8 × 1 = 8
8 × 2 = 16
8 × 3 = 24
8 × 4 = 32
8 × 5 = 40
8 × 6 = 48
8 × 7 = 56
8 × 8 = 64
8 × 9 = 72
9 × 1 = 9
9 × 2 = 18
9 × 3 = 27
9 × 4 = 36
9 × 5 = 45
9 × 6 = 54
9 × 7 = 63
9 × 8 = 72
9 × 9 = 81

while 循环

while循环所做的事概括来讲就是:只要condition条件成立,就一直do something

# 伪代码
while condition:do something

while是关键字;condition是成立的条件;do something是想要做的事

一个简单的例子(注意:这个例子是一个死循环,要及时停止代码,因为当while后条件成立时就会一直执行代码)

# while 1 < 3:
#     print('1 is smaller than 3')

那么应该如何控制while循环呢?一种方式是:在循环过程中制造某种可以使循环停下来的条件,正如下面的例子所示:

count = 0
while True:print('Repeat this line !')count = count + 1if count == 5:break # 若条件成立则终止循环,是终止循环的信号
Repeat this line !
Repeat this line !
Repeat this line !
Repeat this line !
Repeat this line !

while循环停下来的另一种方法是:改变循环成立的条件,用例子说明:给前面的登录函数增加一个新功能,当输入错误密码超过三次后就禁止再次输入密码。

# 创建一个列表,用于储存用户的密码、初始密码和其他数据(对实际数据库进行简化模拟)
password_list = ['*#*#', '12345']# 定义函数
def account_login():tries = 3while tries > 0:password = input('Please input your password:')# 当用户啊输入密码等于列表中最后一个元素(即用户设定的密码),则登录成功password_correct = password == password_list[-1]# 当用户输入密码等于列表中第一个元素时(即重置密码“口令”)则触发密码变更,并将变更的新密码储存至列表的最后一个,成为用户的新密码password_reset = password == password_list[0]if password_correct: # 密码正确print('Login Success!')break # 终止循环elif password_reset: # 密码重置new_password = input('Please enter your new password:')password_list.append(new_password)# 注意上面这句不要漏了,因为密码列表没有变,所以不添加的话密码还是'12345'# 所以需要将新密码添加至password_list中,append默认添加至最后一位print('Your password has changed successfully!')# 这里不需要重新调用函数,因为是要自动循环的,调用函数反而回到起点了,不能终止else: # 若上述情况均不成立,则打印错误提示,并再次运行函数,让用户输入密码print('Wrong password or invalid input!')tries = tries - 1 # 当密码输入错误时,尝试机会减 1,并提示# 这里也不需要调用,原理同上print(tries, 'times left')else: # 这里的else是和while对应的,是while--else结构print('Your account has been suspended')# 调用函数
account_login()
Please input your password: 666
Wrong password or invalid input!
2 times left
Please input your password: 365
Wrong password or invalid input!
1 times left
Please input your password: 125
Wrong password or invalid input!
0 times left
Your account has been suspended

练习题

  1. 设计一个这样的函数,在桌面的文件夹创建10个文本,以数字给它们命名
  2. 复利是一件神奇的事情,正如富兰克林所说:“复利是能够将所有铅块变成金块的石头”。设计一个复利函数invest(), 它包含三个参数:
    account(资金),rate(利率),time(投资时间)。输入每个参数后调用函数,应该返回每一年的资金总额。(假设利率为5%)
  3. 打印1-100内的偶数
# 第 1 题 ,第一次未写出,参考答案
def text_creation():for name in range(1,11):desktop_path = 'C:/Users/username/Desktop/'full_path = desktop_path + str(name) + '.txt'file = open(full_path,'w')file.close()text_creation()
# 第 1 题,第二次做
# 定义函数
def create_text():for num in range(1, 11):path = '/Users/username/Desktop/' + str(num) + '.txt'file = open(path, 'w')file.close()# 答案中open的写法是:# with open(path) as text:#     text.close()# 调用函数
create_text()
# 第 2 题,第一次未写出,参考答案
def invest(amount, rate, time):print("principal amount:{}".format(amount))for t in range(1, time + 1):amount = amount * (1 + rate)# 复利计算:当时的本金乘以(1+利率)print("year {}: ${}".format(t, amount))# 调用
invest(100, 0.05, 8)
invest(2000, 0.025, 5)
principal amount:100
year 1: $105.0
year 2: $110.25
year 3: $115.7625
year 4: $121.55062500000001
year 5: $127.62815625000002
year 6: $134.00956406250003
year 7: $140.71004226562505
year 8: $147.74554437890632
principal amount:2000
year 1: $2050.0
year 2: $2101.25
year 3: $2153.78125
year 4: $2207.62578125
year 5: $2262.8164257812496
# 第 2 题,第二次做
# 假设利率为5%
def invest(amount, time, rate=0.05):print('principal amount:', amount)for year in range(1, time+1):# 复利的计算amount = amount + amount * rateprint('year ', year, ': $', amount)# 调用函数
invest(100, 8)
principal amount: 100
year  1 : $ 105.0
year  2 : $ 110.25
year  3 : $ 115.7625
year  4 : $ 121.550625
year  5 : $ 127.62815624999999
year  6 : $ 134.00956406249998
year  7 : $ 140.71004226562496
year  8 : $ 147.7455443789062
# 第 3 题,第一次做
for num in range(2, 101, 2):print(num)
# 第 3 题,第二次做
def even_print():for i in range(1, 101):if i % 2 == 0: # %是取余运算,//是取整除,即向下取整print(i)
# 调用函数
even_print()
# 第 3 题,参考答案
def even_print():for i in range(1,101):if i%2 == 0: # 能被2整除的数就是偶数print(i)even_print()

综合练习

预备知识:

  1. 对于一个数字列表,使用sum()函数可以对列表中所有的整数求和,如下例所示。
a_list = [1, 2, 3]
print(sum(a_list))
6
  1. Python中的random内置库可以用于生成随机数,此外random中的randrange()方法可以限制生成随机数的范围,如下例所示。
# 导入 random 内置库,用它生成随机数
import random point1 = random.randrange(1,7)
point2 = random.randrange(1,7)
point3 = random.randrange(1,7)print(point1, point2, point3)
5 5 3

游戏开始:押大小,即选择完成后开始摇三个骰子,计算总值。11 <= 总值 <= 18 为“大”,3 <= 总值 <= 10 为“小”,然后告诉玩家猜对或者猜错的结果

import random point1 = random.randrange(1,7)
point2 = random.randrange(1,7)
point3 = random.randrange(1,7)a_list = [point1, point2, point3]
result = sum(a_list)
guess = input('Big or Small: ')
if 3 <= result <= 10 and guess == 'Big':print('The points are {}'.format(a_list), 'You Lose!')
elif 3 <= result <= 10 and guess == 'Small':print('The points are {}'.format(a_list), 'You Win!')
elif 11 <= result <= 18 and guess == 'Big':print('The points are {}'.format(a_list), 'You Win!')
elif 11 <= result <= 18 and guess == 'Small':print('The points are {}'.format(a_list), 'You Lose!')
Big or Small:  Big
The points are [6, 6, 2] You Win!
# 参考答案
# 首先构造摇骰子函数 roll_dice, 调用后返回含三个点数结果的列表
import random
def roll_dice(numbers = 3, points = None):print('<<<<<  ROLL THE DICE!  >>>>>')if points is None:points = []while numbers > 0:point = random.randrange(1,7)points.append(point)numbers = numbers - 1return points # 创建函数:将点数转化为大小,并使用 if 语句来定义什么是“大”,什么是“小”
def roll_result(total):isBig = 11 <= total <= 18isSmall = 3 <= total <= 10if isBig:return 'Big'elif isSmall:return 'Small'# 创建一个开始游戏函数,让用户输入猜大小,并定义什么是猜对,什么是猜错,并输出对应的输赢结果
def start_game():print('<<<<<  GAME STARTS!  >>>>>')choices = ['Big', 'Small']your_choice = input('Big or Small: ')if your_choice in choices:points = roll_dice()total = sum(points)youWin = your_choice == roll_result(total)if youWin:print('The points are ', points, 'You Win !')else:print('The points are ', points, 'You lose !')else:print('Invaild Words')start_game()start_game()
<<<<<  GAME STARTS!  >>>>>
Big or Small:  Big
<<<<<  ROLL THE DICE!  >>>>>
The points are  [3, 1, 5] You lose !

练习题

  1. 较难 在最后一个项目的基础上增加这样的功能,下注金额和赔率。具体规则如下:
  • 初始金额为100元;
  • 金额为0时游戏结束;
  • 默认赔率为1倍,也就是说押对了能得相应金额,押错了会输掉相应金额;
  1. 我们注册应用上时候,常常使用手机号作为账户名,在短信验证之前一般都会检验号码的真实性,如果时不存在的号码就不会发送验证码,
    检验规则如下:
  • 长度不少于11位;
  • 是移动,联通,电信号段中的一个电话号码;
  • 移动号段,联通号段,电信号段如下:
    CN_mobile = [134,135,136,137,138,139,150,151,152,157,158,159,182,183,184,187,188,147,178,1705]
    CN_union = [130,131,132,155,156,185,186,145,176,1709]
    CN_telecom = [133,153,180,181,189,177,1700]
# 第 1 题,结合参考答案 新概念:全局变量
import random
# 设置moneyAll为全局变量,注意:哪里需要全局变量,哪里声明一下;
global moneyAll
moneyAll = 100def roll_dice(numbers=3):print('<<<<< ROLL THE DICE! >>>>>')points=[]while numbers>0:point=random.randrange(1,7)points.append(point)numbers=numbers-1return pointsdef roll_result(total):isBig=11<=total<=18isSmall=3<=total<=10if isBig:return 'Big'elif isSmall:return  'Small'def start_game():# 这个需要使用到上面设置的全局变量,所以要在这重新声明global moneyAllprint('<<<<< GAME STARTS! >>>>>')choices=['Big','Small']your_choice=input('Big or Ssmall:')if your_choice in choices:# input()输入的是字符串,要使用数字运算、比较需要转为int型your_bet = int(input('How much you wanna bet?-'))if moneyAll >= your_bet:points = roll_dice()total = sum(points)youWin = your_choice == roll_result(total)if youWin:print('The points are',points,'You win !')moneyAll += your_betprint('You gained',your_bet,'You have',moneyAll,'now')start_game()else:print('The points are', points, 'You lose !')moneyAll -= your_betprint('You lost', your_bet, 'You have', moneyAll, 'now')if moneyAll == 0:print('GAME OVER')else:start_game()else:print('not full money')start_game()else:print('Invalid Words')start_game()start_game()
<<<<< GAME STARTS! >>>>>
Big or Ssmall: Big
How much you wanna bet?- 150
not full money
<<<<< GAME STARTS! >>>>>
Big or Ssmall: Big
How much you wanna bet?- 80
<<<<< ROLL THE DICE! >>>>>
The points are [3, 1, 4] You lose !
You lost 80 You have 20 now
<<<<< GAME STARTS! >>>>>
Big or Ssmall: Big
How much you wanna bet?- 30
not full money
<<<<< GAME STARTS! >>>>>
Big or Ssmall: Big
How much you wanna bet?- 20
<<<<< ROLL THE DICE! >>>>>
The points are [1, 3, 5] You lose !
You lost 20 You have 0 now
GAME OVER
# 第 2 题
def num_verification():CN_mobile = [134,135,136,137,138,139,150,151,152,157,158,159,182,183,184,187,188,147,178,1705]CN_union = [130,131,132,155,156,185,186,145,176,1709]CN_telecom = [133,153,180,181,189,177,1700]number = input('Please enter your number:')num_length = len(number)# input()的输入是srt型,在这儿切片时需要用到的是int型,所以需要转换数据类型# 为什么不在上面转换,因为转换后不能求len()# 切片的索引是从0开始的,左闭右开first_three = int(number[:3])first_four = int(number[:4])if num_length == 11:if first_three in CN_mobile or first_three in CN_union or first_three in CN_telecom:print('Sending verification code to your phone:', number)elif first_four in CN_mobile or first_four in CN_union or first_four in CN_telecom:print('Sending verification code to your phone:', number)else:print('Invalid phone number')num_verification()else:print('Invalid phone number')num_verification()num_verification()
Please enter your number: 236548
Invalid phone number
Please enter your number: 36578965214
Invalid phone number
Please enter your number: 13025647895
Sending verification code to your phone: 13025647895
# 第 2 题,参考答案
def chephone():phoneNumber=input('Enter Your number:')numlenth=len(phoneNumber)CN_mobile = [134, 135, 136, 137, 138, 139, 150, 151, 152, 157, 158, 159, 182, 183, 184, 187, 188, 147, 178, 1705]CN_union = [130, 131, 132, 155, 156, 185, 186, 145, 176, 1709]CN_telecom = [133, 153, 180, 181, 189, 177, 1700]first_three=int(phoneNumber[0:3])first_four=int(phoneNumber[0:4])if numlenth!=11:print('Invalid length,your number should be in 11 digits')chephone()elif first_three in CN_mobile or first_four in CN_mobile:print('Opetator:China Mobile')print('We\'re sending verification code via text to your phone:',phoneNumber)elif first_three in CN_union or first_four in CN_union:print('Opetator:China Union')print('We\'re sending verification code via text to your phone:', phoneNumber)elif first_three in CN_telecom or first_four in CN_telecom:print('Opetator:China Telecom')print('We\'re sending verification code via text to your phone:', phoneNumber)else:print('No such a operator')chephone()chephone()
Enter Your number: 698546
Invalid length,your number should be in 11 digits
Enter Your number: 32569874563
No such a operator
Enter Your number: 13256987456
Opetator:China Union
We're sending verification code via text to your phone: 13256987456

编程小白的第一本Python入门书学习笔记 Chaper5:循环与判断相关推荐

  1. 编程小白的第一本Python入门书学习笔记 Charper6: 数据结构

    目录 数据与结构 列表(`list`) 列表的增改删查 字典(`Dictionary`) 字典中的增改删查 元组(`Tuple`) 集合(`Set`) 数据结构中的一些技巧 多重循环 列表推导式 循环 ...

  2. 编程小白的第一本Python入门书学习笔记 Chapter4: 函数

    目录 函数的创建 练习题 位置参数与关键词参数 易混淆点:参数名与变量名 默认参数 设计自己的函数 # 伪代码 def function (arg1, arg2):return result def ...

  3. 《编程小白的第一本python入门书》笔记 二

     第四章  函数的魔法 4.1 重新认识函数 a. Python 中所谓的使用函数,就是把你要处理的对象放到一个名字后面的括号里. b.官网中对各个函数的介绍:https://docs.python. ...

  4. 学习python这门课的感受_关于我学习了编程小白的第一本Python入门书之后的感受 200110900207...

    关于我学习了<编程小白的第一本Python入门书>之后的感受 200110900207 计算机类2班 胡敏 其实这本书更多的不是写关于Python的介绍的,而是关于Python的学习,也就 ...

  5. 小白的第一本python书_读书笔记:编程小白的第一本python入门书

    书名:编程小白的第一本python入门书 作者:侯爵 出版社/出处:图灵社区 年份:2016年 封面: 感想: 本书短小精悍,精华部分在于给编程小白打了鸡血的同时输出了一种"高效学习法的思想 ...

  6. 编程小白的第一本python入门书-《编程小白的第一本Python入门书》读书笔记

    对于编程零基础初学者来讲,Python入门选择看什么样的书是很重要的.第一本Python入门书的内容要精简,不然新手学了很久,都还在死磕基础知识.书的难度也不能太高,不然缺乏基础的学习者会看不懂,从而 ...

  7. 编程小白的第一本python入门书-编程小白的第一本 Python 入门书

    编程小白的第一本 Python 入门书 侯爵 (作者) 既然笨办法不能让我学会 Python,那么我决定用一种聪明方法来学,为自己创造学习的捷径.这种高效学习法的核心在于: 1.精简:学习最核心的关键 ...

  8. python编程入门书-编程小白的第一本 Python 入门书

    编程小白的第一本 Python 入门书 侯爵 (作者) 既然笨办法不能让我学会 Python,那么我决定用一种聪明方法来学,为自己创造学习的捷径.这种高效学习法的核心在于: 1.精简:学习最核心的关键 ...

  9. python编程入门书籍-编程小白的第一本 Python 入门书

    编程小白的第一本 Python 入门书 侯爵 (作者) 既然笨办法不能让我学会 Python,那么我决定用一种聪明方法来学,为自己创造学习的捷径.这种高效学习法的核心在于: 1.精简:学习最核心的关键 ...

最新文章

  1. linux c 宏判断多条件 #ifdef 和 #if defined 的区别
  2. 一种Android闪屏页实现方法(偏门别类)
  3. UrlRewrite(Url重写技术)
  4. 【渝粤题库】陕西师范大学400010 当代西方社会思潮评析 作业(专升本)
  5. python xlrd模块_python之xlrd模块
  6. 1038. Jewels And Stones
  7. 【论文解读】Cross-dataset Training for Class Increasing Object Detection
  8. hive SQL Standard Based Hive Authorization 权限自定义(二)
  9. oracle 数据库dg搭建规范1
  10. 奥威软件大数据bi_哪家BI软件能做Sql server的数据可视化分析?
  11. The /usr/local/mysql/data directory is not owned by the 'mysql' to '_mysql' user
  12. 简单的springBoot集成jedis
  13. 小说网站源码+采集器+App端
  14. 自己动手写iPhone wap浏览器之BSD Socket引擎篇
  15. 使用CubeMX配置STM32L476RG,Timer触发ADC采集通过DMA搬运
  16. python变现实现新浪微博登陆
  17. 关于SqlServer练习题
  18. C++秋招春招面试总结
  19. ffmpeg Intel硬件加速总结
  20. [含lw+源码等]javaweb银行柜员业务绩效考核系统

热门文章

  1. 《程序员的创世传说》第三节 魔王与2012 1
  2. 使用quartus生成pof文件
  3. SpaceX载人航天发射,宇航员手动操纵龙飞船进行测试!
  4. 数据可视化工具大全_在线可视化工具大合集
  5. 1-13 StringBuffer和StringBuilder和常用类
  6. 计算机视觉实战--OpenCV进行红绿灯识别
  7. Linux修改时区及设置时间
  8. mmsegmentation使用教程 使用 OpenMMLab 的 MM segmention 下Swin-T 预训练模型 语义分割 推理的记录
  9. linux系统怎么测试udp端口通不通,怎么在Linux服务器上测试TCP/UDP端口的连通性?...
  10. new 关键字有什么作用?