#DICTIONARY
#It is a collection which is unordered, changeable and indexed which doesn't allow duplicate members.
#Dictionary holds key:value pair.
student= {'name' : 'kushagra', 'age' : 23, 'interests' : [ 'Maths' ,'Science']}
print(student)
#accessing value of dictionary
print(student['interests'])
#gives an KeyError if key:value doesn't exist
print(student['hobby'])
#using get function which doesnot give error when data not available
print(student.get('phone'))
#you can also set the return value in case data is not available
print(student.get('name','Not Found'))
print(student.get('phone','Not Found'))
#Adding and Appending Elements to Dict
student['phone']='555-55555'
student['name']='jane'
print(student)
#using update multiple changes at once
student.update({'name': 'yo' , 'age' : 26 , 'phone' : '99-99999'})
print(student)
#Deleting Element
del student['age']
print(student)
#removes the value of given key and stores in the variable
no=student.pop('phone')
print(student)
print(no)
#printing keys of dict
print(student.keys())
#printing values of dict
print(student.values())
#printing items of dict
print(student.items())
#Iterating over dictionary.
for key, value in student.items():
print(key, value)