motorcycles = ["honda", "yamaha", "suzuki"] first_owned = motorcycles.pop(0) print("The first motorcycle I owned was a " + first_owned.title() + ".") 输出为: The first motorcycle I owned was a Honda.…
motorcycle = ["honda", "yamaha", "suzuki"] last_owned = motorcycle.pop() print("The last motorcycle I owned was a " + last_owned.title() + ".") 输出为: The last motorcycle I owned was a Suzuki.…
bicycles = ['trek','cannondale','redline','specialized'] message = "My first bicycle was a " + bicycles[0].title() + "." print(message) 输出为: My first bicycle was a Trek.…
一.逻辑运算符的种类及优先级 ▷逻辑运算符包括 not and or ▷他们的优先级是 () > not > and > or 二.普通逻辑运算 ▷A and B ---> A和B都位真的时候结果为真,有一个为假结果即为假 ▷A or B ---> A和B有一个为真结果即为真 A和B可以为 bool值(True.False),可以为比较运算(3>1 .4<3 .1 !=1 ) 三.两边为数字的逻辑运算 大家都知道,0可以用来表示bool值 False,…
1.变量的命名(): (1).可以包含数字.字母.下划线‘_’,但只能以字母和下划线‘_’开头,不能以数字开头! (2).变量的命名不能包含空格. (3).不能将python中的关键字(reserve words)用来命名: 关键字如下: False class finally is return True continue for lambda try None def from not while and del global or with…
# -*- coding: GBK -*- players = ['charles', 'martina', 'michael', 'florence', 'eli'] print("Here are the first three players on my team:") for player in players[:3]: print (player.title()) 输出为: Here are the first three players on my team: Charle…