print("----")
user_0 = {
'username':'efermi',
'first':'enrico',
'last':'fermi',
}
for key,value in user_0.items():
print('\nkey:'+key)
print('value:'+value)
print('----')
favorite_languages = {
'jen':'python',
'sarah':'c',
'edward':'ruby',
'phil':'python',
}
for name,language in favorite_languages.items():
print(name.title() + "'s favorite language is " + language.title() + '.')
print('----')
favorite_languages = {
'jen':'python',
'sarah':'c',
'edward':'ruby',
'phil':'python',
}
friends = {'phil','sarah'}
for name in favorite_languages.keys():
print(name.title())
if name in friends:
print(" Hi " + name + ", I see your favorite language is "+
favorite_languages[name].title() + "!")
print('----')
favorite_languages = {
'jen':'python',
'sarah':'c',
'edward':'ruby',
'phil':'python',
}
if 'erin' not in favorite_languages.keys():
print("Erin, please take our poll!")
print('----')
favorite_languages = {
'jen':'python',
'sarah':'c',
'edward':'ruby',
'phil':'python',
}
for name in sorted(favorite_languages.keys()):
print(name.title() + ", thank you for taking the poll")
print('----')
favorite_languages = {
'jen':'python',
'sarah':'c',
'edward':'ruby',
'phil':'python',
}
print("The following languages have been mentioned:")
for language in favorite_languages.values():
print(language.title())
print('----')
favorite_languages = {
'jen':'python',
'sarah':'c',
'edward':'ruby',
'phil':'python',
}
print("The following languages have been mentioned:")
for language in set(favorite_languages.values()):
print(language.title())
print("====")
dics = {
'if':'if.',
'print': 'print some text',
'for': 'for loop',
'str': 'str to string',
'and': 'and.',
}
for key,value in dics.items():
print(key + ": " + value + ".")
dics['value'] = "value"
dics['class'] = "class"
dics['int'] = "int"
dics['float'] = "float"
dics['short'] = "short"
print("\n")
for key,value in dics.items():
print(key + ": " + value + ".")
print("====")
items = {
'nile':'egypt',
'chang river':'china',
'yalv river':'korea'
}
for river,country in items.items():
print("The " + river.title() + " runs through " +
country.title() + ".")
for river in items.keys():
print(river.title())
for country in items.values():
print(country.title())
print("====")
favorite_languages = {
'jen':'python',
'sarah':'c',
'edward':'ruby',
'phil':'python',
}
names = ['jen','PiaoYongyou']
for name in favorite_languages.keys():
if name in names:
print("Thank you, " + name)
else:
print("Please come in, " + name)