#6-5 河流
dic = {'The Mississippi River':'America','The Nile':'Egypt','The Yangtze River':'China'}
for river,country in dic.items():
print(river + " runs through " + country + ".")
for river in dic.keys():
print (river)
for country in dic.values():
print (country)
6-6 调查
#6-6 调查
favorite_languages = {'jen':'python','sarah':'c','edward':'ruby','phil':'python',}
list = ['jen','rebecca','edward','cristina']
for name,language in favorite_languages.items():
if name in list:
print(name + ", Thank you very much!")
else:
print(name + ", Welcome to join us!")
6-7 人
#6-7 人
people1 = {'first_name':'Whitney','last_name':'Houston','age':56,'city':'New Jersey'}
people2 = {'first_name':'Jane','last_name':'Zhang','age':34,'city':'Chengdu'}
people3 = {'first_name':'Stefani Joanne Angelina','last_name':'Germanotta','age':32,'city':'Manhattan'}
people = [people1,people2,people3]
for information in people:
print(information)
6-8 宠物
#6-8 宠物
milk = {'type':'cat','master\'s name':'Rebecca'}
jerry = {'type':'dog','master\'s name':'Cristina'}
dudu = {'type':'bird','master\'s name':'Jenny'}
momo = {'type':'tortoise','master\'s name':'Arriana'}
lists = [milk,jerry,dudu,momo]
for animal in lists:
print (animal)
6-9 喜欢的地方
#6-9 喜欢的地方
favorite_places = {'Rebecca':['Japan','China','Egypt'],'Cristina':['France','America','China'],'Arriana':['England','China']}
for name,countries in favorite_places.items():
print (name)
for country in countries:
print (country)
6-10 喜欢的数字
#6-10 喜欢的数字
dic = {'Rebecca':[6,55,264],'Rihana':[8,65,321],'Arriana':[9,88],'Cristina':[50,233],'Jessica':[1,99,666]}
for name,favorite_numbers in dic.items():
print (name)
fornumberin favorite_numbers:
print(number)