Dictionaries
When we save data and also associate a key then we use dictionaries .Furthermore we use dictionaries when we want to store data at the same time and have not one but two sources of data and associate them with each other .
We use curly brackets {} in dictionaries.
-------------------------------------------------------------------------------------
#Syntax:
student={ 'Name ':' Zunair ', 'Age':22 ,'Height ':5.8 }
print(student)
------------------------------------------------------------------------------------
Here i can explain the example with some operation.
#Items
student={ 'Name ':' Zunair ', 'Age':22 ,'Height ':5.8 }
print(student.items())
#Output
#get
student={ 'Name ':' Zunair ', 'Age':22 ,'Height ':5.8 }
print(student.get('Age'))
#Output
# Height
student={ 'Name ':' Zunair ', 'Age':22 ,'Height ':5.8 }
print(student['Height'])
#Output
1 Comments
Thanks sir
ReplyDelete