Dictionary

d1={ } #dictionary
print(type(d1))
d2={"name":"n harish","aim":"softwareharish","gf":"single king","salary":10000}
print(d2)
print(d2["name"])
d2["nick name"]="shiva" #adding another key value pair
print(d2)
del d2["gf"] #delete key value pair
print(d2)

#some functions of dictionary
d3=d2.copy() #copy the dictionary
print(d3)
print(d2.get("aim"))# access key value pair
d2.update({"propery":"laptop"}) #update dictionary
print(d2)
print(d2.keys()) #give all keys of dictionary
print(d2.items()) #give all items of dictionary

Comments

Popular posts from this blog

Steps taken by a compiler to execute a C program

Tokens in C

Variables and Data Types in C