教材第六章课后习题 (部分)
2018-03-23 00:28
435 查看
代码:#6.1
print(6.1)
friend_information = {
'first_name' : 'Jack', 'last_name' : 'Ma',
'age' : 18, 'living city' : 'Hong Kong'}
for key,value in friend_information.items():
print(key,":",value)
print()
#6.5
print(6.5)
dic5 = {'Tom' : 'boy', 'Jack' : 'boy', 'Mary' : 'girl'}
for name,sex in dic5.items():
print(name+" is a "+sex+".")
for name in dic5.keys():
print(name)
for sex in dic5.values():
print(sex)
print()
#6.8
print(6.8)
Tom = {'host':'Tang Mu','age':'3'}
Jack = {'host':'Jie Ke','age':'4'}
Peter = {'host':'Bi De','age':'5'}
pets = [Tom,Jack,Peter]
for pet in pets:
for key,value in pet.items():
print(key + " : " + value,end=" ")
print()
print()
#6.11
print(6.11)
cities = {
'Guangzhou':{'country':'China','Population':'quantities'},
'Beijing':{'country':'China','Population':'lots of'},
'Nanning':{'country':'China','Population':'many'}
}
for city,info in cities.items():
print(city+':')
for key,value in info.items():
print(key+':'+value,end=' ')
print()
print()输出:6.1
first_name : Jack
last_name : Ma
age : 18
living city : Hong Kong
6.5
Tom is a boy.
Jack is a boy.
Mary is a girl.
Tom
Jack
Mary
boy
boy
girl
6.8
host : Tang Mu age : 3
host : Jie Ke age : 4
host : Bi De age : 5
6.11
Guangzhou:
country:China Population:quantities
Beijing:
country:China Population:lots of
Nanning:
country:China Population:many
print(6.1)
friend_information = {
'first_name' : 'Jack', 'last_name' : 'Ma',
'age' : 18, 'living city' : 'Hong Kong'}
for key,value in friend_information.items():
print(key,":",value)
print()
#6.5
print(6.5)
dic5 = {'Tom' : 'boy', 'Jack' : 'boy', 'Mary' : 'girl'}
for name,sex in dic5.items():
print(name+" is a "+sex+".")
for name in dic5.keys():
print(name)
for sex in dic5.values():
print(sex)
print()
#6.8
print(6.8)
Tom = {'host':'Tang Mu','age':'3'}
Jack = {'host':'Jie Ke','age':'4'}
Peter = {'host':'Bi De','age':'5'}
pets = [Tom,Jack,Peter]
for pet in pets:
for key,value in pet.items():
print(key + " : " + value,end=" ")
print()
print()
#6.11
print(6.11)
cities = {
'Guangzhou':{'country':'China','Population':'quantities'},
'Beijing':{'country':'China','Population':'lots of'},
'Nanning':{'country':'China','Population':'many'}
}
for city,info in cities.items():
print(city+':')
for key,value in info.items():
print(key+':'+value,end=' ')
print()
print()输出:6.1
first_name : Jack
last_name : Ma
age : 18
living city : Hong Kong
6.5
Tom is a boy.
Jack is a boy.
Mary is a girl.
Tom
Jack
Mary
boy
boy
girl
6.8
host : Tang Mu age : 3
host : Jie Ke age : 4
host : Bi De age : 5
6.11
Guangzhou:
country:China Population:quantities
Beijing:
country:China Population:lots of
Nanning:
country:China Population:many
相关文章推荐
- 《C语言的科学与艺术》课后习题答案第六章(部分)
- Python教材第六章部分习题
- 教材第八章课后习题 (部分)
- 教材第七章课后习题 (部分)
- 教材第九章课后习题 (部分)
- 教材第十章课后习题 (部分)
- 教材第三章课后习题(部分)
- 鸟哥的Linux私房菜基础学习篇(第二版)第六章课后习题与答案
- 数据结构与算法分析(java语言描述) 部分课后习题答案 第一章
- 《计算机网络》第七版第一章总结及部分课后习题答案
- 第六章部分习题
- 《C语言的科学与艺术》课后习题答案第四章(部分)
- C++primer 第五版课后习题 第六章(1) 1-20
- C++Primer 中文版 第五版 第六章课后习题答案
- How to think like a Computer Scientist: 课后习题第六章 6-12
- 编程珠玑第2章部分课后习题答案注解
- Python教材第七章部分习题
- 电子线路非线性部分课后习题答案
- 《C语言的科学与艺术》课后习题答案第八章(部分)
- 第一章 绪论(及部分课后习题)