Dictionary in python by R4R Team

Python dictionary are the hash table type data. It arrangement are the two dimensional type or we can say each item contain two values ,one is key and another one is value corresponding to their key
Dictionary is the mutable data type
Each item in dictionary are separated by the comma(,) and enclosed in curly parentheses({}) and in each item key and their corresponding values are separated by colon (:)
Example :-
D1={1:'first',2:'second'}
D2={'one':'fisrt', 'two':'second'}

Program-

d1={1:'first',2:'second'}
d2={'one':'fisrt', 'two':'second'}
print(d1)
print(d1[1])
print(d2['two'])
print(len(d1),len(d2))


output

{1: 'first', 2: 'second'}
first
second
2 2


In this program we display the dictionary in different ways. Firstly we display the whole dictionary and then we display the value of key '1' and then further we display the length of the dictionary.

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!