lesson13_ear_16_17_3

d=dict()
for x in range(1,16):
    d[x]=x**2
print(d)

d = {'Red': 1, 'Green': 2, 'Blue': 3} 
for color_key, value in d.items():
     print(color_key, 'corresponds to ', d[color_key]) 

keys = ['red', 'green', 'blue']
values = ['#FF0000','#008000', '#0000FF']
color_dictionary = dict(zip(keys, values))
print(color_dictionary)


color_dict = {'red':'#FF0000',
          'green':'#008000',
          'black':'#000000',
          'white':'#FFFFFF'}

for key in sorted(color_dict):
    print("%s: %s" % (key, color_dict[key]))

myDict = {'a':1,'b':2,'c':3,'d':4}
print(myDict)
if 'a' in myDict: 
    del myDict['a']
print(myDict)


myDict = {'a':2,'b':2,'e':3,'d':4}
result = {}
print myDict
for key,value in myDict.items():
    if value not in result.values():
        result[key] = value

print(result)

 

Posted in Uncategorized