python编程从⼊门到实践第⼆版答案(第三章)
3-1
names = ['day', 'lxd', 'wzy', 'zzz']
print(names[0])
print(names[1])
print(names[2])
print(names[3])
易错 :[]与()是两种格式,⼀个是tuple,⼀个是list
3-2
names = ['day', 'lxd', 'wzy', 'zzz']
print(f"{names[0]},nice to meet you ")
iptables配置命令print(f"{names[1]},nice to meet you ")
print(f"{names[2]},nice to meet you ")
print(f"{names[3]},nice to meet you ")
3-3
cars = ['honda', 'byd', 'bwm', 'zzz']
print(f"I would like to own a {cars[0]} car.")
print(f"I would like to own a {cars[1]} car.")
print(f"I would like to own a {cars[2]} car.")
borderless悦读家print(f"I would like to own a {cars[3]} car.")
3-4
names = ['day', 'lxd', 'wzy', 'zzz']
print(f"{names[0]},I want to invite you to have dinner with me.") print(f"{names[1]},I want to invite you to have dinner with me.") print(f"{names[2]},I want to invite you to have dinner with me.") print(f"{names[3]},I want to invite you to have dinner with me.")
3-5
names = ['day', 'lxd', 'wzy', 'zzz']
print(f"{names[0]},I want to invite you to have dinner with me.") print(f"{names[1]},I want to invite you to have dinner with me.") print(f"{names[2]},I want to invite you to have dinner with me.") print(f"{names[3]},I want to invite you to have dinner with me.\n")
print(f"{names[0]} can't come.\n")
del(names[0])
uiautomation使用详解names.append('zyf')
学python编程入门
print(f"{names[0]},I want to invite you to have dinner with me.") print(f"{names[1]},I want to invite you to have dinner with me.") print(f"{names[2]},I want to invite you to have dinner with me.") print(f"{names[3]},I want to invite you to have dinner with me.")
3-6
names = ['day', 'lxd', 'wzy', 'zzz']
executed翻译print(f"{names[0]},I want to invite you to have dinner with me.") print(f"{names[1]},I want to invite you to have dinner with me.") print(f"{names[2]},I want to invite you to have dinner with me.") print(f"{names[3]},I want to invite you to have dinner with me.\n")
print(f"{names[0]} can't come.\n")
del(names[0])
names.append('zyf')
print(f"{names[0]},I want to invite you to have dinner with me.") print(f"{names[1]},I want to invite you to have dinner with me.") print(f"{names[2]},I want to invite you to have dinner with me.") print(f"{names[3]},I want to invite you to have dinner with me.\n")
print("find more bigger desk\n")
names.insert(0, 'zcy')
names.insert(2, 'sk')
names.append('dq')
for name in names:
print(f"{name},I want to invite you to have dinner with me.")
3-7
names = ['day', 'lxd', 'wzy', 'zzz']
print(f"{names[0]},I want to invite you to have dinner with me.")
print(f"{names[1]},I want to invite you to have dinner with me.")
print(f"{names[2]},I want to invite you to have dinner with me.")
print(f"{names[3]},I want to invite you to have dinner with me.\n") print(f"{names[0]} can't come.\n")
del(names[0])
names.append('zyf')
print(f"{names[0]},I want to invite you to have dinner with me.")
print(f"{names[1]},I want to invite you to have dinner with me.")
print(f"{names[2]},I want to invite you to have dinner with me.")
print(f"{names[3]},I want to invite you to have dinner with me.\n") print("find more bigger desk\n")
names.insert(0, 'zcy')
names.insert(2, 'sk')
names.append('dq')
for name in names:
print(f"{name},I want to invite you to have dinner with me.")
print("sorry ,i can only invite two people.")
ch = names.pop(-1)
print(f"{ch},sorry,i can't invite you.")
ch = names.pop(-1)
print(f"{ch},sorry,i can't invite you.")
ch = names.pop(-1)
print(f"{ch},sorry,i can't invite you.")
ch = names.pop(-1)
print(f"{ch},sorry,i can't invite you.")
ch = names.pop(-1)
print(f"{ch},sorry,i can't invite you.\n")
print(f"{names[0]},i invite you to have dinner.")
print(f"{names[1]},i invite you to have dinner.")
del names[0]
del names[0]
sql修改字段长度#删除⼀个元素后列表只有⼀个元素,如果names[1]将报错
print(names)
易错:删除⼀个元素后列表只有⼀个元素,如果names[1]将报错
3-8
places = ['america', 'china', 'japan', 'iyaly', 'france'] print(sorted(places))
print(places)
print(places)
print(places)
places.sort()
print(places)
places.sort(reverse=True)
print(places)
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论