python第二版第六章课后答案_《Python编程》第六章部分课后练习题
#6-3 词汇表:
代码:#6-3 词汇表
dic = {
'': 'Vectors are sequence containers representing arrays that can change in size.',
'': 'Stacks are a type of container adaptor, specifically designed to operate in '
'a LIFO context (last-in first-out), where elements are inserted and extracted only from one end of the container.',
'': 'Maps are associative containers that store elements formed by a combination of a '
'key value and a mapped value, following a specific order.',
'': 'Sets are containers that store unique elements following a specific order.',
'': 'queues are a type of container adaptor, specifically designed to operate in a'
' FIFO context (first-in first-out), where elements are inserted into one end of the container and extracted from the other.',
}
for key, value in dic.items():
print(key, ':', value, '\n')
输出: : Vectors are sequence containers representing arrays that can change in size.
: Stacks are a type of container adaptor, specifically designed to operate in a LI
FO context (last-in first-out), where elements are inserted and extracted only from one en
d of the container.
: Maps are associative containers that store elements formed by a combination of a k
ey value and a mapped value, following a specific order.
: Sets are containers that store unique elements following a specific order.
: queues are a type of container adaptor, specifically designed to operate in a FI
FO context (first-in first-out), where elements are inserted into one end of the container
and extracted from the other.
#6-5 河流:
代码:#6-5 河流
rivers = {
'nile': 'egypt',
'amazon': 'brazil',
'thames': 'england',
}
for river, country in rivers.items():
message = 'The ' + river.title() + ' runs through ' + country.title()
print(message)
print('\n')
for river in rivers.keys():
print(river.title())
print('\n')
for country in rivers.values():
print(country.title())
输出:The Nile runs through Egypt
The Amazon runs through Brazil
The Thames runs through England
Nile
Amazon
Thames
Egypt
Brazil
England
#6-8 宠物:
代码:#6-8 宠物
dogs = {
'Affenpinscher': 'Smiths',
'Afghan Hound': 'Bob',
'Aidi': 'Peter',
}
cats = {
'Bobtail': 'Lory',
'American Shorthair': 'Peter',
'Bombay': 'Tom',
}
birds = {
'Canary': 'Lory',
'Budgy': 'Tom',
'Cockatiel': 'Bob',
}
pets = [dogs, cats, birds]
for pet in pets:
for name, owner in pet.items():
message = owner + ' has '
if name[0] in 'AOEIU':
message += 'an '
else:
message += 'a '
message += name
print(message)
输出:Smiths has an Affenpinscher
Bob has an Afghan Hound
Peter has an Aidi
Lory has a Bobtail
Peter has an American Shorthair
Tom has a Bombay
Lory has a Canary
Tom has a Budgy
Bob has a Cockatiel
#6-11 城市:
代码:#6-11 城市
Los_Angeles = {
'country': 'USA',
'population': '3,971,883',
'fact': 'It is home to the Wilshire Grand Center, California’s tallest Building.',
}
Guangzhou = {
'country': 'China',
'population': '13,501,100',
'fact': '2008 The 49th World Table Tennis Championships.',
}
Tokyo = {
'country': 'Japan',
'population': '9,262,046',
'fact': 'In 2016, it was to be replaced by the New National Stadium.',
}
cities = {
'Los Angeles': Los_Angeles,
'Guangzhou': Guangzhou,
'Tokyo': Tokyo,
}
for city, dic in cities.items():
message = '\n' + city + ':'
print(message)
for key, value in dic.items():
message = ' ' + key + ': ' + value
print(message)
输出:Los Angeles:
country: USA
population: 3,971,883
fact: It is home to the Wilshire Grand Center, California’s tallest Building.
Guangzhou:
country: China
population: 13,501,100
fact: 2008 The 49th World Table Tennis Championships.
Tokyo:
country: Japan
population: 9,262,046
fact: In 2016, it was to be replaced by the New National Stadium.
python第二版第六章课后答案_《Python编程》第六章部分课后练习题相关推荐
- mysql数据库应用与开发姜桂洪 课后答案_数据库应用与开发姜桂洪课后答案
数据库应用与开发姜桂洪课后答案 设有关系模式r(a,b,c,d),其数据依赖集:f={(a,b)→c,c→d},则关系模式r的规范化程度最高达到( ). 谓词all以子表达式最大值决定主表达式结果 行 ...
- java项目开发教程课后答案_《JavaWeb程序开发入门》课后题
第一章 1.请编写一个格式良好的XML文档,要求包含足球队一支,队名为Madrid,球员5人:Ronaldo.Casillas.Ramos.Modric.Benzema:篮球队一支,队名为Lakers ...
- 黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第四章 使用SCAPY掌控网络(2)Scapy实现ARP缓存投毒
黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第四章 使用SCAPY掌控网络(2)Scapy实现ARP缓存投毒 文章目录 黑帽python第二版(Bl ...
- 黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第一章 配置python环境
黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第一章 配置python环境 文章目录 黑帽python第二版(Black Hat Python 2nd ...
- 黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第五章 WEB黑客(3)暴力破解目录与文件位置
黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第五章 WEB黑客(3)暴力破解目录与文件位置 文章目录 黑帽python第二版(Black Hat P ...
- 黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第五章 WEB黑客(4)暴力破解HTML表单身份验证
黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第五章 WEB黑客(4)暴力破解HTML表单身份验证 文章目录 黑帽python第二版(Black Ha ...
- 黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第三章 网络工程-原始套接字与嗅探(1)主机发现工具与包嗅探
黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第三章 网络工程-原始套接字与嗅探(1)主机发现工具 文章目录 黑帽python第二版(Black Ha ...
- 黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第十一章 攻击性取证
黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第十一章 攻击性取证 文章目录 黑帽python第二版(Black Hat Python 2nd Edi ...
- 黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第八章 Windows常见特洛伊木马任务(1)有趣的键盘记录器
黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第八章 Windows常见特洛伊木马任务(1)有趣的键盘记录器 文章目录 黑帽python第二版(Bla ...
- 黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第八章 Windows常见特洛伊木马任务(4)沙箱检测
黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第八章 Windows常见特洛伊木马任务(4)沙箱检测 文章目录 黑帽python第二版(Black H ...
最新文章
- android 反编译
- 【pmcaff专栏】一个“Uber”血染中国共享经济
- 【数据竞赛】Kaggle竞赛宝典国内外竞赛方案汇总
- 关于Log 的一些东西
- 怎样的项目才能称为“成功项目”?
- linux 拿shell,linux下备份拿shell[渗透必备]
- makefile中的patsubst, wildcard, notdir
- 542. 01 Matrix
- 【计算机网络复习 物理层】2.1.1 物理层基本概念
- 阿里云助力江苏省财政厅力推统一公共支付平台
- Mac开发者福利来了!安利一波各领域不错的软件工具
- 苹果id退出后数据还在吗_【保留数据修复】升级iOS 14后,出现白苹果的修复方法!...
- t6服务器验证密码失败,用友T6软件T6服务无法启动,提示SA密码错误
- 欠款人署名故意签错,怎么维权
- 成为一个好的PHP工程师需要掌握什么技能
- 《那些年啊,那些事——一个程序员的奋斗史》——123
- 项目2-企业级电商平台的搭建--填坑过程
- (萌新笔记)python的复习笔记
- oracle 通过身份证号 查询年龄大于60岁的人
- 知名企业面试、笔试题
热门文章
- OA中总结:s:select,关于使用modelDriven,项目分层,@Transactional,jspf,各个层上配置注解交给spring管理的方法,简单的OGNL表达式写法
- primer premier 5 64位_王者荣耀:必出破军的3位英雄,玩他们不出破军?说明你是个菜鸟!...
- 移动时捕捉不到基点_CAD入门学习攻略:CAD软件中对象捕捉功能使用技巧汇总
- 去掉烦人的“正在配置Windows”
- BAT集体升级云事业部,这背后都藏着哪些“小心思”?
- 关于Exchange邮箱服务器角色故障排查及解决思路分享
- 《C语言点滴》一1.5 内功修炼
- C#MysqlHelper
- 新事务不能登记到指定的事务处理器中异常的处理----MSDTC的正确配置
- SQL Server数据归档的解决方案