Program 1:
Program 2:
Output:
#getting keys and values material={"books":10,"pens":20,"chairs":30} print(material.keys()) #prints all keys print(material.values()) #prints all values
Program 2:
#methods of dictionary x={"name":"amar","branch":"CSE","Rank":5} print(x) print(id(x)) print(x["name"]) print(x.get("name")) x.pop("branch") #removing particular key print(x) x.popitem() #randomly any key will b removed print(x) print(x.clear()) print(type(x),len(x),id(x))
Output: