# 6-8
qinhui = {'breed': 'dog', 'master': 'yuefei'}
yansong = {'breed': 'pig', 'master': 'xujie'}
gaoqiu = {'breed': 'tortoise', 'master': 'linchong'}
pets = [qinhui, yansong, gaoqiu]
for pet in pets:
print(pet)
# 6-9
favorite_places = {
'jian': ['huangshan', 'wuyuan', 'xizang'],
'yang': ['guilin', 'dikengyuan', 'chayeshan'],
'haozi': ['jiaozuo', 'yuntaishan', 'lvzumiao'],
}
for name, places in favorite_places.items():
print(name.title() + " likes: ")
for place in places:
print("\t" + place.title())
# 6-11
cities = {
'henan': {
'country': 'china',
'population': '95.32 million',
'fact': 'There are too many people!',
},
'tokyo': {
'country': 'japan',
'population': '13.50 million',
'fact': 'There are many chusheng in Japan!',
},
'taiwan': {
'country': 'china',
'population': '23.49 million',
'fact': 'Taiwan is an inherent part of China!',
},
}
for city, city_info in cities.items():
print("\nCity: " + city.title())
print("\tCountry: " + city_info['country'])
print("\tPopulation: " + city_info['population'])
print("\tFact: " + city_info['fact'])
{'breed': 'dog', 'master': 'yuefei'}
{'breed': 'pig', 'master': 'xujie'}
{'breed': 'tortoise', 'master': 'linchong'}
Jian likes:
Huangshan
Wuyuan
Xizang
Yang likes:
Guilin
Dikengyuan
Chayeshan
Haozi likes:
Jiaozuo
Yuntaishan
Lvzumiao
City: Henan
Country: china
Population: 95.32 million
Fact: There are too many people!
City: Tokyo
Country: japan
Population: 13.50 million
Fact: There are many chusheng in Japan!
City: Taiwan
Country: china
Population: 23.49 million
Fact: Taiwan is an inherent part of China!
网友评论