IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 人工智能 -> python编程从入门到实践第二版答案(第三章) -> 正文阅读

[人工智能]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 ")
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.")
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])
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.")

3-6

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.")

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]
#删除一个元素后列表只有一个元素,如果names[1]将报错
print(names)

易错:删除一个元素后列表只有一个元素,如果names[1]将报错

3-8

places = ['america', 'china', 'japan', 'iyaly', 'france']
print(sorted(places))
print(places)
places.reverse()
print(places)
places.reverse()
print(places)
places.sort()
print(places)
places.sort(reverse=True)
print(places)

?3-9

names = ['day', 'lxd', 'wzy', 'zzz']
print(len(names))

names.insert(0, 'zcy')
names.insert(2, 'sk')
names.append('dq')
print(len(names))

3-10

?
games = ['lol', 'csgo', 'rust', 'lor']
print(games)
print(f"{games[0]},I think it is best game.")
print(f"{games[1]},I think it is best game.")

del(games[0])
games.append('coh')
games.remove('rust')
games.pop()

games.insert(0, 'dayz')
games.insert(3, 'cf')
games.append('lis')
print(len(games))

print(sorted(games))
games.sort()
print(games)
games.sort(reverse=True)
games.reverse()

?

  人工智能 最新文章
2022吴恩达机器学习课程——第二课(神经网
第十五章 规则学习
FixMatch: Simplifying Semi-Supervised Le
数据挖掘Java——Kmeans算法的实现
大脑皮层的分割方法
【翻译】GPT-3是如何工作的
论文笔记:TEACHTEXT: CrossModal Generaliz
python从零学(六)
详解Python 3.x 导入(import)
【答读者问27】backtrader不支持最新版本的
上一篇文章      下一篇文章      查看所有文章
加:2021-12-02 16:45:14  更:2021-12-02 16:47:22 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/27 2:44:42-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码