#6.1 人people = { "first_name" : 'zetrue' , "last_name": 'Lee' , "age": 20 , "city" : "汕尾" }
print( people)
for key in people.keys() :
print( key , " : " , people[key] )
#6.2 喜欢的数字favorite_val = {'a':1 , 'b':2, 'c':3 , 'd':4 }
for people in favorite_val.keys() :
print( people , " : " , favorite_val[people] )
#6.5 河流rivers = { 'nile':'Egypt' , 'Mississippi' : 'America' , 'Amazon': 'Spain' }
for river in rivers.keys() :
print( "The " + river.title() + " runs through " + rivers[river] )
for river in rivers.keys() :
print( river )
for ele in rivers.values() :
print( ele )
#6.6 调查喜欢的语言people = [ 'a','b','c','d','e']
favorite_languages = { 'a': 'Chinese' , 'e':'English'}
for ele in people :
if ( ele in favorite_languages ) :
print( "Thank you ," , ele )
else :
print( ele , ", Please tell me your favorite language " )
#6.7 人信息people1 = { "first_name" : 'zetrue' , "last_name": 'Lee' , "age": 20 , "city" : "汕尾" }
people2 = { "first_name" : 'yifei' , "last_name": 'Lee' , "age": 20 , "city" : "绥化" }
people3 = { "first_name" : 'yang' , "last_name": 'Lin' , "age": 20 , "city" : "汕头" }
people = [ people1 , people2 , people3 ]
for ele in people :
print ( ele )
#6.8 宠物信息alice = { 'type': 'cat' , 'master':'zetrue' }
bob = { 'type' : 'dog' , 'master': 'yifei' }
mars = {'type' : 'lion' , 'master': 'bruno' }
pets = [ alice , bob , mars ]
for ele in pets :
for key in ele.keys():
print( key , ' ' , ele[key] , end = ' ' )
print()
#6.9 喜欢的地方favorite_places = { 'a':'France' , 'b': 'Polish' , 'c': 'England'}
for ele in favorite_places.keys():
print( ele , " : " , favorite_places[ele] )
#6.11 城市相关信息
Yue = { 'country' : 'guangzhou' , 'population': 1270 , 'fact' : 'food' }
Hu = { 'country' : 'shanghai' , 'population': 2302 , 'fact' : 'beauty' }
Jing = { 'country' : 'beijing' , 'population': 1961 , 'fact' : 'culture' }
cities = { 'guangzhou' : Yue , 'shanghai': Hu , 'beijing' : Jing }
for city in cities.values() :
print( city )