#Netamooz.net
#Learn Python Fast .. All Rights Reserved by Mohammad Shariati Mehr

#declaring the dictionary, dictionary keys and data can be of different data
types 
myDict = {“One”:1.35, 2.5:”Two Point Five”, 3:”+”, 7.9:2} 
#print the entire dictionary 
print(myDict) 
#You’ll get {2.5: 'Two Point Five', 3: '+', 'One': 1.35, 7.9: 2} 
#Note that items in a dictionary are not stored in the same order as the way
you declare them. 
#print the item with key = “One”. 
print(myDict[“One”]) 
#You’ll get 1.35 
#print the item with key = 7.9. 
print(myDict[7.9]) 
#You’ll get 2 
#modify the item with key = 2.5 and print the updated dictionary 
myDict[2.5] = “Two and a Half”

print(myDict) 
#You’ll get {2.5: 'Two and a Half', 3: '+', 'One': 1.35, 7.9: 2} 

#add a new item and print the updated dictionary 
myDict[“New item”] = “I’m new” 
print(myDict) 
#You’ll get {'New item': 'I’m new', 2.5: 'Two and a Half', 3: '+', 'One':
1.35, 7.9: 2} 
#remove the item with key = “One” and print the updated dictionary 
del myDict[“One”] 
print(myDict) 
#You’ll get {'New item': 'I’m new', 2.5: 'Two and a Half', 3: '+', 7.9: 2} 
For more examples and sample codes of working with a dictionary, you can refer to Appendix D. 

